[Math] Mod of a random variable

probability distributions

I had this problem where I wanted to generate random variables (discrete) in a way that certain numbers were more probable than others (basically geometric) but since I wanted to use this number as an array index, I wanted it to be bounded between $[0,n)$, where $n$ could be anything between $5000$ and $10000$ (size of array).

But geometric is not bounded, it can take any value from $0$ to $\infty$. So I was thinking if generated a geometric random variable and took a mod with $n$, I would get what I need but I want to know how will it change the probability distribution i.e. what is the probability distribution of this new random variable $Y = X$ (mod $n$) if $X$ is a geometric random variable with $p$ of, say, $0.5$?

Also, if I may, how will the mod affect a random variable in general?

Best Answer

For any $k$ such that $1\leq k\leq n-1$:

\begin{align} P(Y=k) &= \sum_{j=0}^{\infty} P(X=k+jn) \\ &= \sum_{j=0}^{\infty} q^{k+jn-1}p \\ &= q^{k-1}p \sum_{j=0}^{\infty} \left(q^{n}\right)^j \\ &= \dfrac{q^{k-1}p}{1-q^{n}} = \dfrac{P(X=k)}{1-q^{n}}. \\ \end{align}

Also, the special case of $Y=0$ since $X=0$ can't occur:

\begin{align} P(Y=0) &= \sum_{j=1}^{\infty} P(X=jn) \\ &= \sum_{j=1}^{\infty} q^{jn-1}p \\ &= q^{n-1}p \sum_{j=0}^{\infty} \left(q^{n}\right)^j \\ &= \dfrac{q^{n-1}p}{1-q^{n}} = \dfrac{P(X=n)}{1-q^{n}}. \\ \end{align}

Note that for large $n$, and $p$ not near $0$, the probability distribution of $Y$ is almost the same as that of $X$. For your last question, the effect will depend on the distribution that $X$ has.