Generate a whole random variate uniformly distributed

29 Views Asked by At

I have to describe an algorithm to generate a whole random variate $X$ uniformly distributed on the interval $[a,b]$ where $a,b\ge0, b>a$

I used the inverse trasform algorithm:

STEP1: Generate U $(0,1)$ random variable.

STEP2: The distribibution function of $X$ is: $$F(X)=\left\{\begin{array}{l} 0 \space\space if \space\space x<a \\ (x-a)\div (b-a) \space\space if \space\space a\le x\le b \\ 1 \space \space if \space \space x >b \end{array}\right.$$ Set $F(X) = (X-a) \div (b-a)= U$

Solve for $X$ in terms of $U$ yields:

$X=a+(b-a) \times U $

STEP3: If $X \in Z^+ $ stop, else go to STEP1.

Is it correct?