neulab/docprompting-conala huggingface dataset:
numpy.random.RandomState.poisson method   random.RandomState.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.  Note New code should use the poisson method of a default_rng() instance instead; please see the Quick Start.   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.      See also  Generator.poisson

which should be used for new code.    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
>>> s = np.random.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 = np.random.poisson(lam=(100., 500.), size=(100, 2))
numpy.random.RandomState.power method   random.RandomState.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.  Note New code should use the power method of a default_rng() instance instead; please see the Quick Start.   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.      See also  Generator.power

which should be used for new code.    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: >>> a = 5. # shape
>>> samples = 1000
>>> s = np.random.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 = np.random.power(5, 1000000)
>>> rvsp = np.random.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('np.random.power(5)')
 >>> plt.figure()
>>> plt.hist(1./(1.+rvsp), bins=50, density=True)
>>> plt.plot(xx,powpdf,'r-')  
>>> plt.title('inverse of 1 + np.random.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.RandomState.rand method   random.RandomState.rand(d0, d1, ..., dn)
 
Random values in a given shape.  Note This is a convenience function for users porting code from Matlab, and wraps random_sample. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.  Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).  Parameters 
 
d0, d1, …, dnint, optional


The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.    Returns 
 
outndarray, shape (d0, d1, ..., dn)


Random values.      See also  random
  Examples >>> np.random.rand(3,2)
array([[ 0.14022471,  0.96360618],  #random
       [ 0.37601032,  0.25528411],  #random
       [ 0.49313049,  0.94909878]]) #random
numpy.random.RandomState.randint method   random.RandomState.randint(low, high=None, size=None, dtype=int)
 
Return random integers from low (inclusive) to high (exclusive). Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low).  Note New code should use the integers method of a default_rng() instance instead; please see the Quick Start.   Parameters 
 
lowint or array-like of ints


Lowest (signed) integers to be drawn from the distribution (unless high=None, in which case this parameter is one above the highest such integer).  
highint or array-like of ints, optional


If provided, one above the largest (signed) integer to be drawn from the distribution (see above for behavior if high=None). If array-like, must contain integer values  
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. Byteorder must be native. The default value is int.  New in version 1.11.0.     Returns 
 
outint or ndarray of ints


size-shaped array of random integers from the appropriate distribution, or a single such random int if size not provided.      See also  random_integers

similar to randint, only for the closed interval [low, high], and 1 is the lowest value if high is omitted.  Generator.integers

which should be used for new code.    Examples >>> np.random.randint(2, size=10)
array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0]) # random
>>> np.random.randint(1, size=10)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 Generate a 2 x 4 array of ints between 0 and 4, inclusive: >>> np.random.randint(5, size=(2, 4))
array([[4, 0, 2, 1], # random
       [3, 2, 2, 0]])
 Generate a 1 x 3 array with 3 different upper bounds >>> np.random.randint(1, [3, 5, 10])
array([2, 2, 9]) # random
 Generate a 1 by 3 array with 3 different lower bounds >>> np.random.randint([1, 5, 7], 10)
array([9, 8, 7]) # random
 Generate a 2 by 4 array using broadcasting with dtype of uint8 >>> np.random.randint([1, 3, 5, 7], [[10], [20]], dtype=np.uint8)
array([[ 8,  6,  9,  7], # random
       [ 1, 16,  9, 12]], dtype=uint8)
numpy.random.RandomState.randn method   random.RandomState.randn(d0, d1, ..., dn)
 
Return a sample (or samples) from the “standard normal” distribution.  Note This is a convenience function for users porting code from Matlab, and wraps standard_normal. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.   Note New code should use the standard_normal method of a default_rng() instance instead; please see the Quick Start.  If positive int_like arguments are provided, randn generates an array of shape (d0, d1, ..., dn), filled with random floats sampled from a univariate “normal” (Gaussian) distribution of mean 0 and variance 1. A single float randomly sampled from the distribution is returned if no argument is provided.  Parameters 
 
d0, d1, …, dnint, optional


The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.    Returns 
 
Zndarray or float


A (d0, d1, ..., dn)-shaped array of floating-point samples from the standard normal distribution, or a single such float if no parameters were supplied.      See also  standard_normal

Similar, but takes a tuple as its argument.  normal

Also accepts mu and sigma arguments.  Generator.standard_normal

which should be used for new code.    Notes For random samples from \(N(\mu, \sigma^2)\), use: sigma * np.random.randn(...) + mu Examples >>> np.random.randn()
2.1923875335537315  # random
 Two-by-four array of samples from N(3, 6.25): >>> 3 + 2.5 * np.random.randn(2, 4)
array([[-4.49401501,  4.00950034, -1.81814867,  7.29718677],   # random
       [ 0.39924804,  4.68456316,  4.99394529,  4.84057254]])  # random
numpy.random.RandomState.random_integers method   random.RandomState.random_integers(low, high=None, size=None)
 
Random integers of type np.int_ between low and high, inclusive. Return random integers of type np.int_ from the “discrete uniform” distribution in the closed interval [low, high]. If high is None (the default), then results are from [1, low]. The np.int_ type translates to the C long integer type and its precision is platform dependent. This function has been deprecated. Use randint instead.  Deprecated since version 1.11.0.   Parameters 
 
lowint


Lowest (signed) integer to be drawn from the distribution (unless high=None, in which case this parameter is the highest such integer).  
highint, optional


If provided, the largest (signed) integer to be drawn from the distribution (see above for behavior if high=None).  
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 
 
outint or ndarray of ints


size-shaped array of random integers from the appropriate distribution, or a single such random int if size not provided.      See also  randint

Similar to random_integers, only for the half-open interval [low, high), and 0 is the lowest value if high is omitted.    Notes To sample from N evenly spaced floating-point numbers between a and b, use: a + (b - a) * (np.random.random_integers(N) - 1) / (N - 1.)
 Examples >>> np.random.random_integers(5)
4 # random
>>> type(np.random.random_integers(5))
<class 'numpy.int64'>
>>> np.random.random_integers(5, size=(3,2))
array([[5, 4], # random
       [3, 3],
       [4, 5]])
 Choose five random numbers from the set of five evenly-spaced numbers between 0 and 2.5, inclusive (i.e., from the set \({0, 5/8, 10/8, 15/8, 20/8}\)): >>> 2.5 * (np.random.random_integers(5, size=(5,)) - 1) / 4.
array([ 0.625,  1.25 ,  0.625,  0.625,  2.5  ]) # random
 Roll two six sided dice 1000 times and sum the results: >>> d1 = np.random.random_integers(1, 6, 1000)
>>> d2 = np.random.random_integers(1, 6, 1000)
>>> dsums = d1 + d2
 Display results as a histogram: >>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(dsums, 11, density=True)
>>> plt.show()
numpy.random.RandomState.random_sample method   random.RandomState.random_sample(size=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_sample by (b-a) and add a: (b - a) * random_sample() + a
  Note New code should use the random method of a default_rng() instance instead; please see the Quick Start.   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 
 
outfloat or ndarray of floats


Array of random floats of shape size (unless size=None, in which case a single float is returned).      See also  Generator.random

which should be used for new code.    Examples >>> np.random.random_sample()
0.47108547995356098 # random
>>> type(np.random.random_sample())
<class 'float'>
>>> np.random.random_sample((5,))
array([ 0.30220482,  0.86820401,  0.1654503 ,  0.11659149,  0.54323428]) # random
 Three-by-two array of random numbers from [-5, 0): >>> 5 * np.random.random_sample((3, 2)) - 5
array([[-3.99149989, -0.52338984], # random
       [-2.99091858, -0.79479508],
       [-1.23204345, -1.75224494]])
numpy.random.RandomState.rayleigh method   random.RandomState.rayleigh(scale=1.0, size=None)
 
Draw samples from a Rayleigh distribution. The \(\chi\) and Weibull distributions are generalizations of the Rayleigh.  Note New code should use the rayleigh method of a default_rng() instance instead; please see the Quick Start.   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.      See also  Generator.rayleigh

which should be used for new code.    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
>>> values = hist(np.random.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 = np.random.rayleigh(modevalue, 1000000)
 The percentage of waves larger than 3 meters is: >>> 100.*sum(s>3)/1000000.
0.087300000000000003 # random
numpy.random.RandomState.seed method   random.RandomState.seed(self, seed=None)
 
Reseed a legacy MT19937 BitGenerator Notes This is a convenience, legacy function. The best practice is to not reseed a BitGenerator, rather to recreate a new one. This method is here for legacy reasons. This example demonstrates best practice. >>> from numpy.random import MT19937
>>> from numpy.random import RandomState, SeedSequence
>>> rs = RandomState(MT19937(SeedSequence(123456789)))
# Later, you want to restart the stream
>>> rs = RandomState(MT19937(SeedSequence(987654321)))
numpy.random.RandomState.set_state method   random.RandomState.set_state(state)
 
Set the internal state of the generator from a tuple. For use if one has reason to manually (re-)set the internal state of the bit generator used by the RandomState instance. By default, RandomState uses the “Mersenne Twister”[1] pseudo-random number generating algorithm.  Parameters 
 
state{tuple(str, ndarray of 624 uints, int, int, float), dict}


The state tuple has the following items:  the string ‘MT19937’, specifying the Mersenne Twister algorithm. a 1-D array of 624 unsigned integers keys. an integer pos. an integer has_gauss. a float cached_gaussian.  If state is a dictionary, it is directly set using the BitGenerators state property.    Returns 
 
outNone


Returns ‘None’ on success.      See also  get_state
  Notes set_state and get_state are not needed to work with any of the random distributions in NumPy. If the internal state is manually altered, the user should know exactly what he/she is doing. For backwards compatibility, the form (str, array of 624 uints, int) is also accepted although it is missing some information about the cached Gaussian value: state = ('MT19937', keys, pos). References  1 
M. Matsumoto and T. Nishimura, “Mersenne Twister: A 623-dimensionally equidistributed uniform pseudorandom number generator,” ACM Trans. on Modeling and Computer Simulation, Vol. 8, No. 1, pp. 3-30, Jan. 1998.
numpy.random.RandomState.shuffle method   random.RandomState.shuffle(x)
 
Modify a sequence in-place by shuffling its contents. This function only shuffles the array along the first axis of a multi-dimensional array. The order of sub-arrays is changed but their contents remains the same.  Note New code should use the shuffle method of a default_rng() instance instead; please see the Quick Start.   Parameters 
 
xndarray or MutableSequence


The array, list or mutable sequence to be shuffled.    Returns 
 None
    See also  Generator.shuffle

which should be used for new code.    Examples >>> arr = np.arange(10)
>>> np.random.shuffle(arr)
>>> arr
[1 7 5 2 9 4 3 6 0 8] # random
 Multi-dimensional arrays are only shuffled along the first axis: >>> arr = np.arange(9).reshape((3, 3))
>>> np.random.shuffle(arr)
>>> arr
array([[3, 4, 5], # random
       [6, 7, 8],
       [0, 1, 2]])
numpy.random.RandomState.standard_cauchy method   random.RandomState.standard_cauchy(size=None)
 
Draw samples from a standard Cauchy distribution with mode = 0. Also known as the Lorentz distribution.  Note New code should use the standard_cauchy method of a default_rng() instance instead; please see the Quick Start.   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.      See also  Generator.standard_cauchy

which should be used for new code.    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.standard_cauchy(1000000)
>>> s = s[(s>-25) & (s<25)]  # truncate distribution so it plots well
>>> plt.hist(s, bins=100)
>>> plt.show()
numpy.random.RandomState.standard_exponential method   random.RandomState.standard_exponential(size=None)
 
Draw samples from the standard exponential distribution. standard_exponential is identical to the exponential distribution with a scale parameter of 1.  Note New code should use the standard_exponential method of a default_rng() instance instead; please see the Quick Start.   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 
 
outfloat or ndarray


Drawn samples.      See also  Generator.standard_exponential

which should be used for new code.    Examples Output a 3x8000 array: >>> n = np.random.standard_exponential((3, 8000))
numpy.random.RandomState.standard_gamma method   random.RandomState.standard_gamma(shape, size=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.  Note New code should use the standard_gamma method of a default_rng() instance instead; please see the Quick Start.   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.    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.  Generator.standard_gamma

which should be used for new code.    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.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()