Hi, I am wondering if I am doing this right all along. For simplicity, suppose I am working with the Geometric distribution, which does not have a built-in Stan rng. Can I do this?
real geometric_rng( real theta) {
real u = uniform_rng(0,1);
real x = floor ( log(1-u)/log(1-theta) );
return x;
}
Honestly, my experience suggests this seems ok. But I’d love to know if there is a proper way to do this, assuming there is a closed-form expression for the inverse-CMF (cumulative mass function)?