neulab/docprompting-conala huggingface dataset:
numpy.random.Generator.laplace method   random.Generator.laplace(loc=0.0, scale=1.0, size=None)
 
Draw samples from the Laplace or double exponential distribution with specified location (or mean) and scale (decay). The Laplace distribution is similar to the Gaussian/normal distribution, but is sharper at the peak and has fatter tails. It represents the difference between two independent, identically distributed exponential random variables.  Parameters 
 
locfloat or array_like of floats, optional


The position, \(\mu\), of the distribution peak. Default is 0.  
scalefloat or array_like of floats, optional


\(\lambda\), the exponential decay. Default is 1. 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 loc and scale are both scalars. Otherwise, np.broadcast(loc, scale).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized Laplace distribution.     Notes It has the probability density function  \[f(x; \mu, \lambda) = \frac{1}{2\lambda} \exp\left(-\frac{|x - \mu|}{\lambda}\right).\] The first law of Laplace, from 1774, states that the frequency of an error can be expressed as an exponential function of the absolute magnitude of the error, which leads to the Laplace distribution. For many problems in economics and health sciences, this distribution seems to model the data better than the standard Gaussian distribution. 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 
Kotz, Samuel, et. al. “The Laplace Distribution and Generalizations, ” Birkhauser, 2001.  3 
Weisstein, Eric W. “Laplace Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/LaplaceDistribution.html  4 
Wikipedia, “Laplace distribution”, https://en.wikipedia.org/wiki/Laplace_distribution   Examples Draw samples from the distribution >>> loc, scale = 0., 1.
>>> s = np.random.default_rng().laplace(loc, scale, 1000)
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(s, 30, density=True)
>>> x = np.arange(-8., 8., .01)
>>> pdf = np.exp(-abs(x-loc)/scale)/(2.*scale)
>>> plt.plot(x, pdf)
 Plot Gaussian for comparison: >>> g = (1/(scale * np.sqrt(2 * np.pi)) *
...      np.exp(-(x - loc)**2 / (2 * scale**2)))
>>> plt.plot(x,g)
numpy.random.Generator.logistic method   random.Generator.logistic(loc=0.0, scale=1.0, size=None)
 
Draw samples from a logistic distribution. Samples are drawn from a logistic distribution with specified parameters, loc (location or mean, also median), and scale (>0).  Parameters 
 
locfloat or array_like of floats, optional


Parameter of the distribution. Default is 0.  
scalefloat or array_like of floats, optional


Parameter of the distribution. 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 loc and scale are both scalars. Otherwise, np.broadcast(loc, scale).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized logistic distribution.      See also  scipy.stats.logistic

probability density function, distribution or cumulative density function, etc.    Notes The probability density for the Logistic distribution is  \[P(x) = P(x) = \frac{e^{-(x-\mu)/s}}{s(1+e^{-(x-\mu)/s})^2},\] where \(\mu\) = location and \(s\) = scale. The Logistic distribution is used in Extreme Value problems where it can act as a mixture of Gumbel distributions, in Epidemiology, and by the World Chess Federation (FIDE) where it is used in the Elo ranking system, assuming the performance of each player is a logistically distributed random variable. References  1 
Reiss, R.-D. and Thomas M. (2001), “Statistical Analysis of Extreme Values, from Insurance, Finance, Hydrology and Other Fields,” Birkhauser Verlag, Basel, pp 132-133.  2 
Weisstein, Eric W. “Logistic Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/LogisticDistribution.html  3 
Wikipedia, “Logistic-distribution”, https://en.wikipedia.org/wiki/Logistic_distribution   Examples Draw samples from the distribution: >>> loc, scale = 10, 1
>>> s = np.random.default_rng().logistic(loc, scale, 10000)
>>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(s, bins=50)
 # plot against distribution >>> def logist(x, loc, scale):
...     return np.exp((loc-x)/scale)/(scale*(1+np.exp((loc-x)/scale))**2)
>>> lgst_val = logist(bins, loc, scale)
>>> plt.plot(bins, lgst_val * count.max() / lgst_val.max())
>>> plt.show()
numpy.random.Generator.logseries method   random.Generator.logseries(p, size=None)
 
Draw samples from a logarithmic series distribution. Samples are drawn from a log series distribution with specified shape parameter, 0 < p < 1.  Parameters 
 
pfloat or array_like of floats


Shape parameter for the distribution. Must be in the range (0, 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 p is a scalar. Otherwise, np.array(p).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized logarithmic series distribution.      See also  scipy.stats.logser

probability density function, distribution or cumulative density function, etc.    Notes The probability mass function for the Log Series distribution is  \[P(k) = \frac{-p^k}{k \ln(1-p)},\] where p = probability. The log series distribution is frequently used to represent species richness and occurrence, first proposed by Fisher, Corbet, and Williams in 1943 [2]. It may also be used to model the numbers of occupants seen in cars [3]. References  1 
Buzas, Martin A.; Culver, Stephen J., Understanding regional species diversity through the log series distribution of occurrences: BIODIVERSITY RESEARCH Diversity & Distributions, Volume 5, Number 5, September 1999 , pp. 187-195(9).  2 
Fisher, R.A,, A.S. Corbet, and C.B. Williams. 1943. The relation between the number of species and the number of individuals in a random sample of an animal population. Journal of Animal Ecology, 12:42-58.  3 
D. J. Hand, F. Daly, D. Lunn, E. Ostrowski, A Handbook of Small Data Sets, CRC Press, 1994.  4 
Wikipedia, “Logarithmic distribution”, https://en.wikipedia.org/wiki/Logarithmic_distribution   Examples Draw samples from the distribution: >>> a = .6
>>> s = np.random.default_rng().logseries(a, 10000)
>>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(s)
 # plot against distribution >>> def logseries(k, p):
...     return -p**k/(k*np.log(1-p))
>>> plt.plot(bins, logseries(bins, a) * count.max()/
...          logseries(bins, a).max(), 'r')
>>> plt.show()
numpy.random.Generator.negative_binomial method   random.Generator.negative_binomial(n, p, size=None)
 
Draw samples from a negative binomial distribution. Samples are drawn from a negative binomial distribution with specified parameters, n successes and p probability of success where n is > 0 and p is in the interval (0, 1].  Parameters 
 
nfloat or array_like of floats


Parameter of the distribution, > 0.  
pfloat or array_like of floats


Parameter of the distribution. Must satisfy 0 < p <= 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 n and p are both scalars. Otherwise, np.broadcast(n, p).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized negative binomial distribution, where each sample is equal to N, the number of failures that occurred before a total of n successes was reached.     Notes The probability mass function of the negative binomial distribution is  \[P(N;n,p) = \frac{\Gamma(N+n)}{N!\Gamma(n)}p^{n}(1-p)^{N},\] where \(n\) is the number of successes, \(p\) is the probability of success, \(N+n\) is the number of trials, and \(\Gamma\) is the gamma function. When \(n\) is an integer, \(\frac{\Gamma(N+n)}{N!\Gamma(n)} = \binom{N+n-1}{N}\), which is the more common form of this term in the the pmf. The negative binomial distribution gives the probability of N failures given n successes, with a success on the last trial. If one throws a die repeatedly until the third time a “1” appears, then the probability distribution of the number of non-“1”s that appear before the third “1” is a negative binomial distribution. References  1 
Weisstein, Eric W. “Negative Binomial Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/NegativeBinomialDistribution.html  2 
Wikipedia, “Negative binomial distribution”, https://en.wikipedia.org/wiki/Negative_binomial_distribution   Examples Draw samples from the distribution: A real world example. A company drills wild-cat oil exploration wells, each with an estimated probability of success of 0.1. What is the probability of having one success for each successive well, that is what is the probability of a single success after drilling 5 wells, after 6 wells, etc.? >>> s = np.random.default_rng().negative_binomial(1, 0.1, 100000)
>>> for i in range(1, 11): 
...    probability = sum(s<i) / 100000.
...    print(i, "wells drilled, probability of one success =", probability)
numpy.random.Generator.noncentral_chisquare method   random.Generator.noncentral_chisquare(df, nonc, size=None)
 
Draw samples from a noncentral chi-square distribution. The noncentral \(\chi^2\) distribution is a generalization of the \(\chi^2\) distribution.  Parameters 
 
dffloat or array_like of floats


Degrees of freedom, must be > 0.  Changed in version 1.10.0: Earlier NumPy versions required dfnum > 1.   
noncfloat or array_like of floats


Non-centrality, 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 df and nonc are both scalars. Otherwise, np.broadcast(df, nonc).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized noncentral chi-square distribution.     Notes The probability density function for the noncentral Chi-square distribution is  \[P(x;df,nonc) = \sum^{\infty}_{i=0} \frac{e^{-nonc/2}(nonc/2)^{i}}{i!} P_{Y_{df+2i}}(x),\] where \(Y_{q}\) is the Chi-square with q degrees of freedom. References  1 
Wikipedia, “Noncentral chi-squared distribution” https://en.wikipedia.org/wiki/Noncentral_chi-squared_distribution   Examples Draw values from the distribution and plot the histogram >>> rng = np.random.default_rng()
>>> import matplotlib.pyplot as plt
>>> values = plt.hist(rng.noncentral_chisquare(3, 20, 100000),
...                   bins=200, density=True)
>>> plt.show()
    Draw values from a noncentral chisquare with very small noncentrality, and compare to a chisquare. >>> plt.figure()
>>> values = plt.hist(rng.noncentral_chisquare(3, .0000001, 100000),
...                   bins=np.arange(0., 25, .1), density=True)
>>> values2 = plt.hist(rng.chisquare(3, 100000),
...                    bins=np.arange(0., 25, .1), density=True)
>>> plt.plot(values[1][0:-1], values[0]-values2[0], 'ob')
>>> plt.show()
    Demonstrate how large values of non-centrality lead to a more symmetric distribution. >>> plt.figure()
>>> values = plt.hist(rng.noncentral_chisquare(3, 20, 100000),
...                   bins=200, density=True)
>>> plt.show()
numpy.random.Generator.noncentral_f method   random.Generator.noncentral_f(dfnum, dfden, nonc, size=None)
 
Draw samples from the noncentral F distribution. Samples are drawn from an F distribution with specified parameters, dfnum (degrees of freedom in numerator) and dfden (degrees of freedom in denominator), where both parameters > 1. nonc is the non-centrality parameter.  Parameters 
 
dfnumfloat or array_like of floats


Numerator degrees of freedom, must be > 0.  Changed in version 1.14.0: Earlier NumPy versions required dfnum > 1.   
dfdenfloat or array_like of floats


Denominator degrees of freedom, must be > 0.  
noncfloat or array_like of floats


Non-centrality parameter, the sum of the squares of the numerator means, 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 dfnum, dfden, and nonc are all scalars. Otherwise, np.broadcast(dfnum, dfden, nonc).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized noncentral Fisher distribution.     Notes When calculating the power of an experiment (power = probability of rejecting the null hypothesis when a specific alternative is true) the non-central F statistic becomes important. When the null hypothesis is true, the F statistic follows a central F distribution. When the null hypothesis is not true, then it follows a non-central F statistic. References  1 
Weisstein, Eric W. “Noncentral F-Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/NoncentralF-Distribution.html  2 
Wikipedia, “Noncentral F-distribution”, https://en.wikipedia.org/wiki/Noncentral_F-distribution   Examples In a study, testing for a specific alternative to the null hypothesis requires use of the Noncentral F distribution. We need to calculate the area in the tail of the distribution that exceeds the value of the F distribution for the null hypothesis. We’ll plot the two probability distributions for comparison. >>> rng = np.random.default_rng()
>>> dfnum = 3 # between group deg of freedom
>>> dfden = 20 # within groups degrees of freedom
>>> nonc = 3.0
>>> nc_vals = rng.noncentral_f(dfnum, dfden, nonc, 1000000)
>>> NF = np.histogram(nc_vals, bins=50, density=True)
>>> c_vals = rng.f(dfnum, dfden, 1000000)
>>> F = np.histogram(c_vals, bins=50, density=True)
>>> import matplotlib.pyplot as plt
>>> plt.plot(F[1][1:], F[0])
>>> plt.plot(NF[1][1:], NF[0])
>>> plt.show()
numpy.random.Generator.normal method   random.Generator.normal(loc=0.0, scale=1.0, size=None)
 
Draw random samples from a normal (Gaussian) distribution. The probability density function of the normal distribution, first derived by De Moivre and 200 years later by both Gauss and Laplace independently [2], is often called the bell curve because of its characteristic shape (see the example below). The normal distributions occurs often in nature. For example, it describes the commonly occurring distribution of samples influenced by a large number of tiny, random disturbances, each with its own unique distribution [2].  Parameters 
 
locfloat or array_like of floats


Mean (“centre”) of the distribution.  
scalefloat or array_like of floats


Standard deviation (spread or “width”) 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 loc and scale are both scalars. Otherwise, np.broadcast(loc, scale).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized normal distribution.      See also  scipy.stats.norm

probability density function, distribution or cumulative density function, etc.    Notes The probability density for the Gaussian distribution is  \[p(x) = \frac{1}{\sqrt{ 2 \pi \sigma^2 }} e^{ - \frac{ (x - \mu)^2 } {2 \sigma^2} },\] where \(\mu\) is the mean and \(\sigma\) the standard deviation. The square of the standard deviation, \(\sigma^2\), is called the variance. The function has its peak at the mean, and its “spread” increases with the standard deviation (the function reaches 0.607 times its maximum at \(x + \sigma\) and \(x - \sigma\) [2]). This implies that normal is more likely to return samples lying close to the mean, rather than those far away. References  1 
Wikipedia, “Normal distribution”, https://en.wikipedia.org/wiki/Normal_distribution  
2(1,2,3)
 
P. R. Peebles Jr., “Central Limit Theorem” in “Probability, Random Variables and Random Signal Principles”, 4th ed., 2001, pp. 51, 51, 125.   Examples Draw samples from the distribution: >>> mu, sigma = 0, 0.1 # mean and standard deviation
>>> s = np.random.default_rng().normal(mu, sigma, 1000)
 Verify the mean and the variance: >>> abs(mu - np.mean(s))
0.0  # may vary
 >>> abs(sigma - np.std(s, ddof=1))
0.0  # may vary
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(s, 30, density=True)
>>> plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) *
...                np.exp( - (bins - mu)**2 / (2 * sigma**2) ),
...          linewidth=2, color='r')
>>> plt.show()
    Two-by-four array of samples from N(3, 6.25): >>> np.random.default_rng().normal(3, 2.5, 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.pareto method   random.Generator.pareto(a, size=None)
 
Draw samples from a Pareto II or Lomax distribution with specified shape. The Lomax or Pareto II distribution is a shifted Pareto distribution. The classical Pareto distribution can be obtained from the Lomax distribution by adding 1 and multiplying by the scale parameter m (see Notes). The smallest value of the Lomax distribution is zero while for the classical Pareto distribution it is mu, where the standard Pareto distribution has location mu = 1. Lomax can also be considered as a simplified version of the Generalized Pareto distribution (available in SciPy), with the scale set to one and the location set to zero. The Pareto distribution must be greater than zero, and is unbounded above. It is also known as the “80-20 rule”. In this distribution, 80 percent of the weights are in the lowest 20 percent of the range, while the other 20 percent fill the remaining 80 percent of the range.  Parameters 
 
afloat or array_like of floats


Shape of the distribution. Must be positive.  
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 Pareto distribution.      See also  scipy.stats.lomax

probability density function, distribution or cumulative density function, etc.  scipy.stats.genpareto

probability density function, distribution or cumulative density function, etc.    Notes The probability density for the Pareto distribution is  \[p(x) = \frac{am^a}{x^{a+1}}\] where \(a\) is the shape and \(m\) the scale. The Pareto distribution, named after the Italian economist Vilfredo Pareto, is a power law probability distribution useful in many real world problems. Outside the field of economics it is generally referred to as the Bradford distribution. Pareto developed the distribution to describe the distribution of wealth in an economy. It has also found use in insurance, web page access statistics, oil field sizes, and many other problems, including the download frequency for projects in Sourceforge [1]. It is one of the so-called “fat-tailed” distributions. References  1 
Francis Hunt and Paul Johnson, On the Pareto Distribution of Sourceforge projects.  2 
Pareto, V. (1896). Course of Political Economy. Lausanne.  3 
Reiss, R.D., Thomas, M.(2001), Statistical Analysis of Extreme Values, Birkhauser Verlag, Basel, pp 23-30.  4 
Wikipedia, “Pareto distribution”, https://en.wikipedia.org/wiki/Pareto_distribution   Examples Draw samples from the distribution: >>> a, m = 3., 2.  # shape and mode
>>> s = (np.random.default_rng().pareto(a, 1000) + 1) * m
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> count, bins, _ = plt.hist(s, 100, density=True)
>>> fit = a*m**a / bins**(a+1)
>>> plt.plot(bins, max(count)*fit/max(fit), linewidth=2, color='r')
>>> plt.show()
numpy.random.Generator.permutation method   random.Generator.permutation(x, axis=0)
 
Randomly permute a sequence, or return a permuted range.  Parameters 
 
xint or array_like


If x is an integer, randomly permute np.arange(x). If x is an array, make a copy and shuffle the elements randomly.  
axisint, optional


The axis which x is shuffled along. Default is 0.    Returns 
 
outndarray


Permuted sequence or array range.     Examples >>> rng = np.random.default_rng()
>>> rng.permutation(10)
array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6]) # random
 >>> rng.permutation([1, 4, 9, 12, 15])
array([15,  1,  9,  4, 12]) # random
 >>> arr = np.arange(9).reshape((3, 3))
>>> rng.permutation(arr)
array([[6, 7, 8], # random
       [0, 1, 2],
       [3, 4, 5]])
 >>> rng.permutation("abc")
Traceback (most recent call last):
    ...
numpy.AxisError: axis 0 is out of bounds for array of dimension 0
 >>> arr = np.arange(9).reshape((3, 3))
>>> rng.permutation(arr, axis=1)
array([[0, 2, 1], # random
       [3, 5, 4],
       [6, 8, 7]])
numpy.random.Generator.permuted method   random.Generator.permuted(x, axis=None, out=None)
 
Randomly permute x along axis axis. Unlike shuffle, each slice along the given axis is shuffled independently of the others.  Parameters 
 
xarray_like, at least one-dimensional


Array to be shuffled.  
axisint, optional


Slices of x in this axis are shuffled. Each slice is shuffled independently of the others. If axis is None, the flattened array is shuffled.  
outndarray, optional


If given, this is the destinaton of the shuffled array. If out is None, a shuffled copy of the array is returned.    Returns 
 ndarray

If out is None, a shuffled copy of x is returned. Otherwise, the shuffled array is stored in out, and out is returned      See also  shuffle
permutation
  Examples Create a numpy.random.Generator instance: >>> rng = np.random.default_rng()
 Create a test array: >>> x = np.arange(24).reshape(3, 8)
>>> x
array([[ 0,  1,  2,  3,  4,  5,  6,  7],
       [ 8,  9, 10, 11, 12, 13, 14, 15],
       [16, 17, 18, 19, 20, 21, 22, 23]])
 Shuffle the rows of x: >>> y = rng.permuted(x, axis=1)
>>> y
array([[ 4,  3,  6,  7,  1,  2,  5,  0],  # random
       [15, 10, 14,  9, 12, 11,  8, 13],
       [17, 16, 20, 21, 18, 22, 23, 19]])
 x has not been modified: >>> x
array([[ 0,  1,  2,  3,  4,  5,  6,  7],
       [ 8,  9, 10, 11, 12, 13, 14, 15],
       [16, 17, 18, 19, 20, 21, 22, 23]])
 To shuffle the rows of x in-place, pass x as the out parameter: >>> y = rng.permuted(x, axis=1, out=x)
>>> x
array([[ 3,  0,  4,  7,  1,  6,  2,  5],  # random
       [ 8, 14, 13,  9, 12, 11, 15, 10],
       [17, 18, 16, 22, 19, 23, 20, 21]])
 Note that when the out parameter is given, the return value is out: >>> y is x
True