I would like to try from a zipf distribution from a limited domain.
That is, suppose the domain is {1, ..., N}, I would like each element in the region, i, to be selected with a probability proportional i ** -ato where athe distribution parameter is.
numpy provides a zipf sampler (numpy.random.zipf), but it does not allow me to limit the domain.
How can I easily choose from such a distribution?
If the distribution parameter is agreater than 1, I can use the sampler numpy, rejecting (and re-sampling) all samples in excess N. However, since it does not limit the sampling range, trying to use any lower values adoes not work.
When the domain is finite, there should be no problem using that as, and this is what I need for my application.
source
share