Skip to content

Fix mean and variance with mode le truncated min#2

Open
rjvdboon wants to merge 2 commits intoMantiMantilla:mainfrom
rjvdboon:fix_mean_and_variance_with_mode_le_truncated_min
Open

Fix mean and variance with mode le truncated min#2
rjvdboon wants to merge 2 commits intoMantiMantilla:mainfrom
rjvdboon:fix_mean_and_variance_with_mode_le_truncated_min

Conversation

@rjvdboon
Copy link

@rjvdboon rjvdboon commented Mar 24, 2023

With the truncated triangular distribution, when the Mode of the base triangular distribution was less or equal the truncated minimum of the truncated triangular distribution, then the computed Mean and Variance were incorrect.
For the mean and variance, the integrals should not have been from M to b, but from a to b, e.g.
$\int_a^b{....}dx$ instead of $\int_M^b{...}dx$.
This of course changes the numerator for the mean and variance. I noticed this first when for certain parameters the computed variance was negative (which should be impossible). And the simulated variance and mean were nowhere near the computed variance and mean.

I used Wolfram Alpha to convert the (new) integrals to the correct functions, see e.g. Variance Case 3

I also extended the simulation script to be able to easily handle different test cases, and fixes drawing from the distribution for "Case 3".

@rjvdboon
Copy link
Author

This should fix Issue #3

@MantiMantilla
Copy link
Owner

I'll take a look at this soon!! Thank you for looking at this in such depth. Just out of curiosity, what are you working on that would use this VERY OLD project?

@rjvdboon
Copy link
Author

rjvdboon commented May 9, 2023

I'll take a look at this soon!! Thank you for looking at this in such depth. Just out of curiosity, what are you working on that would use this VERY OLD project?

OLD is in the eye of the beholder... 😄 I have a 10+ year old project in C# that includes a few distribution functions. I wanted to add a truncated triangular distribution (next to the existing triangular distribution), and your page is the only good source I could find on a truncated triangular. Apart from the problems in the Mean/Variance I found the explanation in the pages very helpful to brush up my (somewhat rusty) statistical skills.

@MantiMantilla
Copy link
Owner

That sounds wonderful!! Do share your project if it's publicly available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants