neulab/docprompting-conala huggingface dataset:
numpy.random.RandomState.get_state method   random.RandomState.get_state()
 
Return a tuple representing the internal state of the generator. For more details, see set_state.  Parameters 
 
legacybool, optional


Flag indicating to return a legacy tuple state when the BitGenerator is MT19937, instead of a dict.    Returns 
 
out{tuple(str, ndarray of 624 uints, int, int, float), dict}


The returned tuple has the following items:  the string ‘MT19937’. a 1-D array of 624 unsigned integer keys. an integer pos. an integer has_gauss. a float cached_gaussian.  If legacy is False, or the BitGenerator is not MT19937, then state is returned as a dictionary.      See also  set_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.
numpy.random.RandomState.laplace method   random.RandomState.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.  Note New code should use the laplace method of a default_rng() instance instead; please see the Quick Start.   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.      See also  Generator.laplace

which should be used for new code.    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.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.RandomState.logistic method   random.RandomState.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).  Note New code should use the logistic method of a default_rng() instance instead; please see the Quick Start.   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.  Generator.logistic

which should be used for new code.    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.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.RandomState.logseries method   random.RandomState.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.  Note New code should use the logseries method of a default_rng() instance instead; please see the Quick Start.   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.  Generator.logseries

which should be used for new code.    Notes The probability density 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.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.RandomState.multinomial method   random.RandomState.multinomial(n, pvals, size=None)
 
Draw samples from a multinomial distribution. The multinomial distribution is a multivariate generalization of the binomial distribution. Take an experiment with one of p possible outcomes. An example of such an experiment is throwing a dice, where the outcome can be 1 through 6. Each sample drawn from the distribution represents n such experiments. Its values, X_i = [X_0, X_1, ..., X_p], represent the number of times the outcome was i.  Note New code should use the multinomial method of a default_rng() instance instead; please see the Quick Start.   Parameters 
 
nint


Number of experiments.  
pvalssequence of floats, length p


Probabilities of each of the p different outcomes. These must sum to 1 (however, the last element is always assumed to account for the remaining probability, as long as sum(pvals[:-1]) <= 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. Default is None, in which case a single value is returned.    Returns 
 
outndarray


The drawn samples, of shape size, if that was provided. If not, the shape is (N,). In other words, each entry out[i,j,...,:] is an N-dimensional value drawn from the distribution.      See also  Generator.multinomial

which should be used for new code.    Examples Throw a dice 20 times: >>> np.random.multinomial(20, [1/6.]*6, size=1)
array([[4, 1, 7, 5, 2, 1]]) # random
 It landed 4 times on 1, once on 2, etc. Now, throw the dice 20 times, and 20 times again: >>> np.random.multinomial(20, [1/6.]*6, size=2)
array([[3, 4, 3, 3, 4, 3], # random
       [2, 4, 3, 4, 0, 7]])
 For the first run, we threw 3 times 1, 4 times 2, etc. For the second, we threw 2 times 1, 4 times 2, etc. A loaded die is more likely to land on number 6: >>> np.random.multinomial(100, [1/7.]*5 + [2/7.])
array([11, 16, 14, 17, 16, 26]) # random
 The probability inputs should be normalized. As an implementation detail, the value of the last entry is ignored and assumed to take up any leftover probability mass, but this should not be relied on. A biased coin which has twice as much weight on one side as on the other should be sampled like so: >>> np.random.multinomial(100, [1.0 / 3, 2.0 / 3])  # RIGHT
array([38, 62]) # random
 not like: >>> np.random.multinomial(100, [1.0, 2.0])  # WRONG
Traceback (most recent call last):
ValueError: pvals < 0, pvals > 1 or pvals contains NaNs
numpy.random.RandomState.negative_binomial method   random.RandomState.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].  Note New code should use the negative_binomial method of a default_rng() instance instead; please see the Quick Start.   Parameters 
 
nfloat or array_like of floats


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


Parameter of the distribution, >= 0 and <=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.      See also  Generator.negative_binomial

which should be used for new code.    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.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.RandomState.noncentral_chisquare method   random.RandomState.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.  Note New code should use the noncentral_chisquare method of a default_rng() instance instead; please see the Quick Start.   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.      See also  Generator.noncentral_chisquare

which should be used for new code.    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 >>> import matplotlib.pyplot as plt
>>> values = plt.hist(np.random.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(np.random.noncentral_chisquare(3, .0000001, 100000),
...                   bins=np.arange(0., 25, .1), density=True)
>>> values2 = plt.hist(np.random.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(np.random.noncentral_chisquare(3, 20, 100000),
...                   bins=200, density=True)
>>> plt.show()
numpy.random.RandomState.noncentral_f method   random.RandomState.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.  Note New code should use the noncentral_f method of a default_rng() instance instead; please see the Quick Start.   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.      See also  Generator.noncentral_f

which should be used for new code.    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. >>> dfnum = 3 # between group deg of freedom
>>> dfden = 20 # within groups degrees of freedom
>>> nonc = 3.0
>>> nc_vals = np.random.noncentral_f(dfnum, dfden, nonc, 1000000)
>>> NF = np.histogram(nc_vals, bins=50, density=True)
>>> c_vals = np.random.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.RandomState.normal method   random.RandomState.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].  Note New code should use the normal method of a default_rng() instance instead; please see the Quick Start.   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.  Generator.normal

which should be used for new code.    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.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.1  # 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.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.RandomState.permutation method   random.RandomState.permutation(x)
 
Randomly permute a sequence, or return a permuted range. If x is a multi-dimensional array, it is only shuffled along its first index.  Note New code should use the permutation method of a default_rng() instance instead; please see the Quick Start.   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.    Returns 
 
outndarray


Permuted sequence or array range.      See also  Generator.permutation

which should be used for new code.    Examples >>> np.random.permutation(10)
array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6]) # random
 >>> np.random.permutation([1, 4, 9, 12, 15])
array([15,  1,  9,  4, 12]) # random
 >>> arr = np.arange(9).reshape((3, 3))
>>> np.random.permutation(arr)
array([[6, 7, 8], # random
       [0, 1, 2],
       [3, 4, 5]])