1
$\begingroup$

I am trying to generate an asymetric triangular distribution; a is lower limit, b is higher limit and c is mode.

I found this following way to generate a random variable $X$ with triangular distribution.

Let $β = (c-a)/(b-a)$
Let $U_1$ and $U_2$ be uniform on $[0,1]$
If $(U_1 ≤ β)$
$X = a + (c-a)\sqrt U_2$
Else
$X = b - (b-c)\sqrt U_2$

As far as I understood:
Let $f(X)$ be pdf of triangular distribution. I think our $U_1$ determines whether our random variable X is smaller or greater than c. Since $β$ equals to the probability that a given number is smaller than c, this makes sense. After that, based on where $X$ value lies, we are generating a random variable with uniform distribution. If $X<$ c, X is uniformly distributed on [a,c], otherwise between [c,b] (but its cdf is decreasing).

However my beloved logic falls apart at one point. Why do we need to take square root of $U_1$? What am I missing?

Thanks in advance.

  • 0
    @marvinthemartian: By the way, the $\sqrt{U}$ was not arrived at by magic. One standard way to simulate$a$random variable $X$ is by using $F_X^{-1}(U)$, where $F_X^{-1}(x)$ is the inverse function of the cumulative distribution function of $X$.2012-03-01

0 Answers 0