I am trying to generate a random integer that follows this distribution.
$$ P(X=k)=p(1-p)^{k-1}$$
for
$$ k=1,2,…$$
I tried to use sample with some numbers, but i do not know how to use the distribution.
distributionsrrandom-generationsample
I am trying to generate a random integer that follows this distribution.
$$ P(X=k)=p(1-p)^{k-1}$$
for
$$ k=1,2,…$$
I tried to use sample with some numbers, but i do not know how to use the distribution.
Best Answer
This is the probability mass function of the geometric distribution.
If you use R: To sample from the geometric distribution, first specify the probability $p$ and then use the
rgeom
function: