Generating Random variables for Exponential distribution (long series)

80 Views Asked by At

I have number series (1,2,3,......100) . I want to get random variable based on exponential increasing probability distribution such that 1 has lowest probability of being chosen and 100 has highest. I managed to get solution for low number series like from 1,2,3.... 32 but for 1 to 100 series the solution is not practical. how can i get exponential random variables for this long series (1 to 100).

1

There are 1 best solutions below

8
On

Say $X$ runs from $1$ to $N$ inclusive, with $P(X=x)=\frac{r^x-r^{x-1}}{r^N-1},\,r>1$ and $P(X\le x)=\frac{r^x-1}{r^N-1}$. Sample $U\sim U(0,\,1)$, solve $\frac{r^x-1}{r^N-1}=U$ for real $x$, viz. $x=\log_r(1+U(r^N-1))$, then set $X=\lceil x\rceil$.