[Math] Truncated Geometric Distribution

probabilityprobability distributionssimulation

I have equation for truncated increasing geometric distribution given as
$ pr=\frac{ (1-\alpha) \alpha^{CW}} { 1- \alpha^{CW} }. \alpha^{-r} $ with $ r=1, ….., CW $. $\alpha$ is parameter we can set between 0 and 1.

Here probability of picking r=1 is very low and r=CW is very high. How can i derive an equation from this equation that should give me values generated between r= 1 and CW with given distribution.
i should get values like this if r=1 to 10. CW=10
10,10,9,9,6,1,6,10,10,3,4 (following geometric distribution from equation provided)

Thanks in advance

Best Answer

The standard way to generate a geometric variable with probability mass function $P(n)=(1-p)p^n$ for $n\in\mathbb N_0$ from a variable $u$ uniformly distributed over $[0,1]$ is

$$ n=\left\lfloor\frac{\log u}{\log p}\right\rfloor\;. $$

To restrict to $0\le n\lt CW$, we need to transform $u$ to $[u_0,1]$ such that $\frac{\log u_0}{\log p}=CW$. Thus $u_0=p^{CW}$, so you can use $u\to 1-u\left(1-p^{CW}\right)$, and the formula for generating $n$ becomes

$$ n=\left\lfloor\frac{\log\left(1-u\left(1-p^{CW}\right)\right)}{\log p}\right\rfloor\;. $$

To map this to your case, take $r=CW-n$ and $p=\alpha$.

Related Question