neulab/docprompting-conala huggingface dataset:
numpy.random.Generator.poisson method   random.Generator.poisson(lam=1.0, size=None)
 
Draw samples from a Poisson distribution. The Poisson distribution is the limit of the binomial distribution for large N.  Parameters 
 
lamfloat or array_like of floats


Expected number of events occurring in a fixed-time interval, must be >= 0. A sequence must be broadcastable over the requested size.  
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if lam is a scalar. Otherwise, np.array(lam).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized Poisson distribution.     Notes The Poisson distribution  \[f(k; \lambda)=\frac{\lambda^k e^{-\lambda}}{k!}\] For events with an expected separation \(\lambda\) the Poisson distribution \(f(k; \lambda)\) describes the probability of \(k\) events occurring within the observed interval \(\lambda\). Because the output is limited to the range of the C int64 type, a ValueError is raised when lam is within 10 sigma of the maximum representable value. References  1 
Weisstein, Eric W. “Poisson Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/PoissonDistribution.html  2 
Wikipedia, “Poisson distribution”, https://en.wikipedia.org/wiki/Poisson_distribution   Examples Draw samples from the distribution: >>> import numpy as np
>>> rng = np.random.default_rng()
>>> s = rng.poisson(5, 10000)
 Display histogram of the sample: >>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(s, 14, density=True)
>>> plt.show()
    Draw each 100 values for lambda 100 and 500: >>> s = rng.poisson(lam=(100., 500.), size=(100, 2))
numpy.random.Generator.power method   random.Generator.power(a, size=None)
 
Draws samples in [0, 1] from a power distribution with positive exponent a - 1. Also known as the power function distribution.  Parameters 
 
afloat or array_like of floats


Parameter of the distribution. Must be non-negative.  
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if a is a scalar. Otherwise, np.array(a).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized power distribution.    Raises 
 ValueError

If a <= 0.     Notes The probability density function is  \[P(x; a) = ax^{a-1}, 0 \le x \le 1, a>0.\] The power function distribution is just the inverse of the Pareto distribution. It may also be seen as a special case of the Beta distribution. It is used, for example, in modeling the over-reporting of insurance claims. References  1 
Christian Kleiber, Samuel Kotz, “Statistical size distributions in economics and actuarial sciences”, Wiley, 2003.  2 
Heckert, N. A. and Filliben, James J. “NIST Handbook 148: Dataplot Reference Manual, Volume 2: Let Subcommands and Library Functions”, National Institute of Standards and Technology Handbook Series, June 2003. https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/powpdf.pdf   Examples Draw samples from the distribution: >>> rng = np.random.default_rng()
>>> a = 5. # shape
>>> samples = 1000
>>> s = rng.power(a, samples)
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(s, bins=30)
>>> x = np.linspace(0, 1, 100)
>>> y = a*x**(a-1.)
>>> normed_y = samples*np.diff(bins)[0]*y
>>> plt.plot(x, normed_y)
>>> plt.show()
    Compare the power function distribution to the inverse of the Pareto. >>> from scipy import stats  
>>> rvs = rng.power(5, 1000000)
>>> rvsp = rng.pareto(5, 1000000)
>>> xx = np.linspace(0,1,100)
>>> powpdf = stats.powerlaw.pdf(xx,5)  
 >>> plt.figure()
>>> plt.hist(rvs, bins=50, density=True)
>>> plt.plot(xx,powpdf,'r-')  
>>> plt.title('power(5)')
 >>> plt.figure()
>>> plt.hist(1./(1.+rvsp), bins=50, density=True)
>>> plt.plot(xx,powpdf,'r-')  
>>> plt.title('inverse of 1 + Generator.pareto(5)')
 >>> plt.figure()
>>> plt.hist(1./(1.+rvsp), bins=50, density=True)
>>> plt.plot(xx,powpdf,'r-')  
>>> plt.title('inverse of stats.pareto(5)')
numpy.random.Generator.random method   random.Generator.random(size=None, dtype=np.float64, out=None)
 
Return random floats in the half-open interval [0.0, 1.0). Results are from the “continuous uniform” distribution over the stated interval. To sample \(Unif[a, b), b > a\) multiply the output of random by (b-a) and add a: (b - a) * random() + a
  Parameters 
 
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.  
dtypedtype, optional


Desired dtype of the result, only float64 and float32 are supported. Byteorder must be native. The default value is np.float64.  
outndarray, optional


Alternative output array in which to place the result. If size is not None, it must have the same shape as the provided size and must match the type of the output values.    Returns 
 
outfloat or ndarray of floats


Array of random floats of shape size (unless size=None, in which case a single float is returned).     Examples >>> rng = np.random.default_rng()
>>> rng.random()
0.47108547995356098 # random
>>> type(rng.random())
<class 'float'>
>>> rng.random((5,))
array([ 0.30220482,  0.86820401,  0.1654503 ,  0.11659149,  0.54323428]) # random
 Three-by-two array of random numbers from [-5, 0): >>> 5 * rng.random((3, 2)) - 5
array([[-3.99149989, -0.52338984], # random
       [-2.99091858, -0.79479508],
       [-1.23204345, -1.75224494]])
numpy.random.Generator.rayleigh method   random.Generator.rayleigh(scale=1.0, size=None)
 
Draw samples from a Rayleigh distribution. The \(\chi\) and Weibull distributions are generalizations of the Rayleigh.  Parameters 
 
scalefloat or array_like of floats, optional


Scale, also equals the mode. Must be non-negative. Default is 1.  
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if scale is a scalar. Otherwise, np.array(scale).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized Rayleigh distribution.     Notes The probability density function for the Rayleigh distribution is  \[P(x;scale) = \frac{x}{scale^2}e^{\frac{-x^2}{2 \cdotp scale^2}}\] The Rayleigh distribution would arise, for example, if the East and North components of the wind velocity had identical zero-mean Gaussian distributions. Then the wind speed would have a Rayleigh distribution. References  1 
Brighton Webs Ltd., “Rayleigh Distribution,” https://web.archive.org/web/20090514091424/http://brighton-webs.co.uk:80/distributions/rayleigh.asp  2 
Wikipedia, “Rayleigh distribution” https://en.wikipedia.org/wiki/Rayleigh_distribution   Examples Draw values from the distribution and plot the histogram >>> from matplotlib.pyplot import hist
>>> rng = np.random.default_rng()
>>> values = hist(rng.rayleigh(3, 100000), bins=200, density=True)
 Wave heights tend to follow a Rayleigh distribution. If the mean wave height is 1 meter, what fraction of waves are likely to be larger than 3 meters? >>> meanvalue = 1
>>> modevalue = np.sqrt(2 / np.pi) * meanvalue
>>> s = rng.rayleigh(modevalue, 1000000)
 The percentage of waves larger than 3 meters is: >>> 100.*sum(s>3)/1000000.
0.087300000000000003 # random
numpy.random.Generator.shuffle method   random.Generator.shuffle(x, axis=0)
 
Modify an array or sequence in-place by shuffling its contents. The order of sub-arrays is changed but their contents remains the same.  Parameters 
 
xndarray or MutableSequence


The array, list or mutable sequence to be shuffled.  
axisint, optional


The axis which x is shuffled along. Default is 0. It is only supported on ndarray objects.    Returns 
 None
   Examples >>> rng = np.random.default_rng()
>>> arr = np.arange(10)
>>> rng.shuffle(arr)
>>> arr
[1 7 5 2 9 4 3 6 0 8] # random
 >>> arr = np.arange(9).reshape((3, 3))
>>> rng.shuffle(arr)
>>> arr
array([[3, 4, 5], # random
       [6, 7, 8],
       [0, 1, 2]])
 >>> arr = np.arange(9).reshape((3, 3))
>>> rng.shuffle(arr, axis=1)
>>> arr
array([[2, 0, 1], # random
       [5, 3, 4],
       [8, 6, 7]])
numpy.random.Generator.standard_cauchy method   random.Generator.standard_cauchy(size=None)
 
Draw samples from a standard Cauchy distribution with mode = 0. Also known as the Lorentz distribution.  Parameters 
 
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.    Returns 
 
samplesndarray or scalar


The drawn samples.     Notes The probability density function for the full Cauchy distribution is  \[P(x; x_0, \gamma) = \frac{1}{\pi \gamma \bigl[ 1+ (\frac{x-x_0}{\gamma})^2 \bigr] }\] and the Standard Cauchy distribution just sets \(x_0=0\) and \(\gamma=1\) The Cauchy distribution arises in the solution to the driven harmonic oscillator problem, and also describes spectral line broadening. It also describes the distribution of values at which a line tilted at a random angle will cut the x axis. When studying hypothesis tests that assume normality, seeing how the tests perform on data from a Cauchy distribution is a good indicator of their sensitivity to a heavy-tailed distribution, since the Cauchy looks very much like a Gaussian distribution, but with heavier tails. References  1 
NIST/SEMATECH e-Handbook of Statistical Methods, “Cauchy Distribution”, https://www.itl.nist.gov/div898/handbook/eda/section3/eda3663.htm  2 
Weisstein, Eric W. “Cauchy Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/CauchyDistribution.html  3 
Wikipedia, “Cauchy distribution” https://en.wikipedia.org/wiki/Cauchy_distribution   Examples Draw samples and plot the distribution: >>> import matplotlib.pyplot as plt
>>> s = np.random.default_rng().standard_cauchy(1000000)
>>> s = s[(s>-25) & (s<25)]  # truncate distribution so it plots well
>>> plt.hist(s, bins=100)
>>> plt.show()
numpy.random.Generator.standard_exponential method   random.Generator.standard_exponential(size=None, dtype=np.float64, method='zig', out=None)
 
Draw samples from the standard exponential distribution. standard_exponential is identical to the exponential distribution with a scale parameter of 1.  Parameters 
 
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.  
dtypedtype, optional


Desired dtype of the result, only float64 and float32 are supported. Byteorder must be native. The default value is np.float64.  
methodstr, optional


Either ‘inv’ or ‘zig’. ‘inv’ uses the default inverse CDF method. ‘zig’ uses the much faster Ziggurat method of Marsaglia and Tsang.  
outndarray, optional


Alternative output array in which to place the result. If size is not None, it must have the same shape as the provided size and must match the type of the output values.    Returns 
 
outfloat or ndarray


Drawn samples.     Examples Output a 3x8000 array: >>> n = np.random.default_rng().standard_exponential((3, 8000))
numpy.random.Generator.standard_gamma method   random.Generator.standard_gamma(shape, size=None, dtype=np.float64, out=None)
 
Draw samples from a standard Gamma distribution. Samples are drawn from a Gamma distribution with specified parameters, shape (sometimes designated “k”) and scale=1.  Parameters 
 
shapefloat or array_like of floats


Parameter, must be non-negative.  
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if shape is a scalar. Otherwise, np.array(shape).size samples are drawn.  
dtypedtype, optional


Desired dtype of the result, only float64 and float32 are supported. Byteorder must be native. The default value is np.float64.  
outndarray, optional


Alternative output array in which to place the result. If size is not None, it must have the same shape as the provided size and must match the type of the output values.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized standard gamma distribution.      See also  scipy.stats.gamma

probability density function, distribution or cumulative density function, etc.    Notes The probability density for the Gamma distribution is  \[p(x) = x^{k-1}\frac{e^{-x/\theta}}{\theta^k\Gamma(k)},\] where \(k\) is the shape and \(\theta\) the scale, and \(\Gamma\) is the Gamma function. The Gamma distribution is often used to model the times to failure of electronic components, and arises naturally in processes for which the waiting times between Poisson distributed events are relevant. References  1 
Weisstein, Eric W. “Gamma Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/GammaDistribution.html  2 
Wikipedia, “Gamma distribution”, https://en.wikipedia.org/wiki/Gamma_distribution   Examples Draw samples from the distribution: >>> shape, scale = 2., 1. # mean and width
>>> s = np.random.default_rng().standard_gamma(shape, 1000000)
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> import scipy.special as sps  
>>> count, bins, ignored = plt.hist(s, 50, density=True)
>>> y = bins**(shape-1) * ((np.exp(-bins/scale))/  
...                       (sps.gamma(shape) * scale**shape))
>>> plt.plot(bins, y, linewidth=2, color='r')  
>>> plt.show()
numpy.random.Generator.standard_normal method   random.Generator.standard_normal(size=None, dtype=np.float64, out=None)
 
Draw samples from a standard Normal distribution (mean=0, stdev=1).  Parameters 
 
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.  
dtypedtype, optional


Desired dtype of the result, only float64 and float32 are supported. Byteorder must be native. The default value is np.float64.  
outndarray, optional


Alternative output array in which to place the result. If size is not None, it must have the same shape as the provided size and must match the type of the output values.    Returns 
 
outfloat or ndarray


A floating-point array of shape size of drawn samples, or a single sample if size was not specified.      See also  normal

Equivalent function with additional loc and scale arguments for setting the mean and standard deviation.    Notes For random samples from \(N(\mu, \sigma^2)\), use one of: mu + sigma * rng.standard_normal(size=...)
rng.normal(mu, sigma, size=...)
 Examples >>> rng = np.random.default_rng()
>>> rng.standard_normal()
2.1923875335537315 # random
 >>> s = rng.standard_normal(8000)
>>> s
array([ 0.6888893 ,  0.78096262, -0.89086505, ...,  0.49876311,  # random
       -0.38672696, -0.4685006 ])                                # random
>>> s.shape
(8000,)
>>> s = rng.standard_normal(size=(3, 4, 2))
>>> s.shape
(3, 4, 2)
 Two-by-four array of samples from \(N(3, 6.25)\): >>> 3 + 2.5 * rng.standard_normal(size=(2, 4))
array([[-4.49401501,  4.00950034, -1.81814867,  7.29718677],   # random
       [ 0.39924804,  4.68456316,  4.99394529,  4.84057254]])  # random
numpy.random.Generator.triangular method   random.Generator.triangular(left, mode, right, size=None)
 
Draw samples from the triangular distribution over the interval [left, right]. The triangular distribution is a continuous probability distribution with lower limit left, peak at mode, and upper limit right. Unlike the other distributions, these parameters directly define the shape of the pdf.  Parameters 
 
leftfloat or array_like of floats


Lower limit.  
modefloat or array_like of floats


The value where the peak of the distribution occurs. The value must fulfill the condition left <= mode <= right.  
rightfloat or array_like of floats


Upper limit, must be larger than left.  
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if left, mode, and right are all scalars. Otherwise, np.broadcast(left, mode, right).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized triangular distribution.     Notes The probability density function for the triangular distribution is  \[\begin{split}P(x;l, m, r) = \begin{cases} \frac{2(x-l)}{(r-l)(m-l)}& \text{for $l \leq x \leq m$},\\ \frac{2(r-x)}{(r-l)(r-m)}& \text{for $m \leq x \leq r$},\\ 0& \text{otherwise}. \end{cases}\end{split}\] The triangular distribution is often used in ill-defined problems where the underlying distribution is not known, but some knowledge of the limits and mode exists. Often it is used in simulations. References  1 
Wikipedia, “Triangular distribution” https://en.wikipedia.org/wiki/Triangular_distribution   Examples Draw values from the distribution and plot the histogram: >>> import matplotlib.pyplot as plt
>>> h = plt.hist(np.random.default_rng().triangular(-3, 0, 8, 100000), bins=200,
...              density=True)
>>> plt.show()
numpy.random.Generator.uniform method   random.Generator.uniform(low=0.0, high=1.0, size=None)
 
Draw samples from a uniform distribution. Samples are uniformly distributed over the half-open interval [low, high) (includes low, but excludes high). In other words, any value within the given interval is equally likely to be drawn by uniform.  Parameters 
 
lowfloat or array_like of floats, optional


Lower boundary of the output interval. All values generated will be greater than or equal to low. The default value is 0.  
highfloat or array_like of floats


Upper boundary of the output interval. All values generated will be less than high. The high limit may be included in the returned array of floats due to floating-point rounding in the equation low + (high-low) * random_sample(). high - low must be non-negative. The default value is 1.0.  
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if low and high are both scalars. Otherwise, np.broadcast(low, high).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized uniform distribution.      See also  integers

Discrete uniform distribution, yielding integers.  random

Floats uniformly distributed over [0, 1).    Notes The probability density function of the uniform distribution is  \[p(x) = \frac{1}{b - a}\] anywhere within the interval [a, b), and zero elsewhere. When high == low, values of low will be returned. Examples Draw samples from the distribution: >>> s = np.random.default_rng().uniform(-1,0,1000)
 All values are within the given interval: >>> np.all(s >= -1)
True
>>> np.all(s < 0)
True
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(s, 15, density=True)
>>> plt.plot(bins, np.ones_like(bins), linewidth=2, color='r')
>>> plt.show()
numpy.random.Generator.vonmises method   random.Generator.vonmises(mu, kappa, size=None)
 
Draw samples from a von Mises distribution. Samples are drawn from a von Mises distribution with specified mode (mu) and dispersion (kappa), on the interval [-pi, pi]. The von Mises distribution (also known as the circular normal distribution) is a continuous probability distribution on the unit circle. It may be thought of as the circular analogue of the normal distribution.  Parameters 
 
mufloat or array_like of floats


Mode (“center”) of the distribution.  
kappafloat or array_like of floats


Dispersion of the distribution, has to be >=0.  
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if mu and kappa are both scalars. Otherwise, np.broadcast(mu, kappa).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized von Mises distribution.      See also  scipy.stats.vonmises

probability density function, distribution, or cumulative density function, etc.    Notes The probability density for the von Mises distribution is  \[p(x) = \frac{e^{\kappa cos(x-\mu)}}{2\pi I_0(\kappa)},\] where \(\mu\) is the mode and \(\kappa\) the dispersion, and \(I_0(\kappa)\) is the modified Bessel function of order 0. The von Mises is named for Richard Edler von Mises, who was born in Austria-Hungary, in what is now the Ukraine. He fled to the United States in 1939 and became a professor at Harvard. He worked in probability theory, aerodynamics, fluid mechanics, and philosophy of science. References  1 
Abramowitz, M. and Stegun, I. A. (Eds.). “Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, 9th printing,” New York: Dover, 1972.  2 
von Mises, R., “Mathematical Theory of Probability and Statistics”, New York: Academic Press, 1964.   Examples Draw samples from the distribution: >>> mu, kappa = 0.0, 4.0 # mean and dispersion
>>> s = np.random.default_rng().vonmises(mu, kappa, 1000)
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> from scipy.special import i0  
>>> plt.hist(s, 50, density=True)
>>> x = np.linspace(-np.pi, np.pi, num=51)
>>> y = np.exp(kappa*np.cos(x-mu))/(2*np.pi*i0(kappa))  
>>> plt.plot(x, y, linewidth=2, color='r')  
>>> plt.show()
numpy.random.Generator.wald method   random.Generator.wald(mean, scale, size=None)
 
Draw samples from a Wald, or inverse Gaussian, distribution. As the scale approaches infinity, the distribution becomes more like a Gaussian. Some references claim that the Wald is an inverse Gaussian with mean equal to 1, but this is by no means universal. The inverse Gaussian distribution was first studied in relationship to Brownian motion. In 1956 M.C.K. Tweedie used the name inverse Gaussian because there is an inverse relationship between the time to cover a unit distance and distance covered in unit time.  Parameters 
 
meanfloat or array_like of floats


Distribution mean, must be > 0.  
scalefloat or array_like of floats


Scale parameter, must be > 0.  
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if mean and scale are both scalars. Otherwise, np.broadcast(mean, scale).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized Wald distribution.     Notes The probability density function for the Wald distribution is  \[P(x;mean,scale) = \sqrt{\frac{scale}{2\pi x^3}}e^ \frac{-scale(x-mean)^2}{2\cdotp mean^2x}\] As noted above the inverse Gaussian distribution first arise from attempts to model Brownian motion. It is also a competitor to the Weibull for use in reliability modeling and modeling stock returns and interest rate processes. References  1 
Brighton Webs Ltd., Wald Distribution, https://web.archive.org/web/20090423014010/http://www.brighton-webs.co.uk:80/distributions/wald.asp  2 
Chhikara, Raj S., and Folks, J. Leroy, “The Inverse Gaussian Distribution: Theory : Methodology, and Applications”, CRC Press, 1988.  3 
Wikipedia, “Inverse Gaussian distribution” https://en.wikipedia.org/wiki/Inverse_Gaussian_distribution   Examples Draw values from the distribution and plot the histogram: >>> import matplotlib.pyplot as plt
>>> h = plt.hist(np.random.default_rng().wald(3, 2, 100000), bins=200, density=True)
>>> plt.show()