MATLAB: How to generate integer random variables by using exponentially distributed with a mean of 20 seconds

exponentially distributedrandom variables

I used this code that you see in below but this all values, I generate, not integer:
mu2 = 20;
sz1 = 50;
sz2 = 1;
r2 = exprnd(mu2,sz1,sz2)

Best Answer

If you just want integers, then use the geometric distribution instead of the exponential:
r2 = geornd(1/mu2,sz1,sz2);