numpy
lets you generate random samples from a beta distribution (or any other arbitrary distribution) with this API:
samples = np.random.beta(a,b, size=1000)
What is this doing beneath the hood? Inverse Transform Sampling?
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.
Sign up to join this communitynumpy
lets you generate random samples from a beta distribution (or any other arbitrary distribution) with this API:
samples = np.random.beta(a,b, size=1000)
What is this doing beneath the hood? Inverse Transform Sampling?
The code for numpy.random.beta
is found at legacy-distributions.c at the time of this writing.
Notice that numpy.random.*
functions (including numpy.random.beta
) became legacy functions since NumPy 1.17 introduced a new system for pseudorandom number generation (see the NumPy RNG Policy). Thus, the implementation of numpy.random.beta
is not expected to change for as long as numpy.random.*
functions are still present in NumPy, and the beta generator used in the new RNG system may differ from the one presented here.
In fact, at the time of this writing, the new generator is slightly different from the legacy generator (see distributions.c at the time of this writing), and one of the reasons for introducing the new RNG system is to allow the non-uniform random generators to be improved without having to maintain backward compatibility.
REFERENCES:
numpy.random.binomial
and numpy.random.*
overall, but I don't think the answers the question. What method does numpy.random.beta
use to generate random values?
$\endgroup$
numpy.random.beta
works.
$\endgroup$