Fix mean and variance with mode le truncated min#2
Fix mean and variance with mode le truncated min#2rjvdboon wants to merge 2 commits intoMantiMantilla:mainfrom
Conversation
|
This should fix Issue #3 |
|
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. |
|
That sounds wonderful!! Do share your project if it's publicly available. |
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.
$\int_a^b{....}dx$ instead of $\int_M^b{...}dx$ .
For the mean and variance, the integrals should not have been from
Mtob, but fromatob, e.g.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".