|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <k46k48$7s3$1@newscl01ah.mathworks.com>...
> Might I ask you Roger what leads you to this formula?
> You don't need to elaborate the calculation details, just explaining the overall approach will satisfy me. Thanks.
> Bruno
- - - - - - - - - -
The triangular distribution f(x|a,b,c) as defined in Wikipedia:
http://en.wikipedia.org/wiki/Triangular_distribution
is the same as the distribution of the x-coordinates of a statistically uniform distribution of (x,y) points in the interior of the triangle (a,1),(b,1),(c,0), and that is what my method is based on. The y-coordinates would be given by the sqrt(rand(n,1)) factor.
This approach admittedly has the disadvantage of requiring twice as many calls on 'rand' to achieve the same result as yours, Bruno, though it has fewer lines of code.
Roger Stafford
|