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 ** -a
to where a
the 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 a
greater 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 a
does not work.
When the domain is finite, there should be no problem using that a
s, and this is what I need for my application.
source
share