SROU is based on the ratio-of-uniforms method that uses universal inequalities for
constructing a (universal) bounding rectangle. It works for T-concave distributions
with T(x)=-1/sqrt(x). The main advantage of the method is a fast setup. This
can be beneficial if one repeatedly needs to generate small to moderate samples of
a distribution with different shape parameters. In such a situation, the setup step of
NumericalInverseHermite or NumericalInversePolynomial will lead to poor performance.
Parameters:
distobject
An instance of a class with pdf method.
pdf: PDF of the distribution. The signature of the PDF is
expected to be: defpdf(self,x:float)->float. i.e.
the PDF should accept a Python float and
return a Python float. It doesn’t need to integrate to 1 i.e.
the PDF doesn’t need to be normalized. If not normalized, pdf_area
should be set to the area under the PDF.
modefloat, optional
(Exact) Mode of the distribution. When the mode is None, a slow
numerical routine is used to approximate it. Default is None.
pdf_areafloat, optional
Area under the PDF. Optionally, an upper bound to the area under
the PDF can be passed at the cost of increased rejection constant.
Default is 1.
domainlist or tuple of length 2, optional
The support of the distribution.
Default is None. When None:
If a support method is provided by the distribution object
dist, it is used to set the domain of the distribution.
Otherwise the support is assumed to be \((-\infty, \infty)\).
cdf_at_modefloat, optional
CDF at the mode. It can be given to increase the performance of the
algorithm. The rejection constant is halfed when CDF at mode is given.
Default is None.
A NumPy random number generator or seed for the underlying NumPy random
number generator used to generate the stream of uniform random numbers.
If random_state is None (or np.random), the numpy.random.RandomState
singleton is used.
If random_state is an int, a new RandomState instance is used,
seeded with random_state.
If random_state is already a Generator or RandomState instance then
that instance is used.
Notice that the PDF doesn’t integrate to 1. We can either pass the exact
area under the PDF during initialization of the generator or an upper
bound to the exact area under the PDF. Also, it is recommended to pass
the mode of the distribution to speed up the setup: