neulab/docprompting-conala huggingface dataset:
numpy.random.Generator.weibull method   random.Generator.weibull(a, size=None)
 
Draw samples from a Weibull distribution. Draw samples from a 1-parameter Weibull distribution with the given shape parameter a.  \[X = (-ln(U))^{1/a}\] Here, U is drawn from the uniform distribution over (0,1]. The more common 2-parameter Weibull, including a scale parameter \(\lambda\) is just \(X = \lambda(-ln(U))^{1/a}\).  Parameters 
 
afloat or array_like of floats


Shape parameter of the distribution. Must be nonnegative.  
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 Weibull distribution.      See also  scipy.stats.weibull_max
scipy.stats.weibull_min
scipy.stats.genextreme
gumbel
  Notes The Weibull (or Type III asymptotic extreme value distribution for smallest values, SEV Type III, or Rosin-Rammler distribution) is one of a class of Generalized Extreme Value (GEV) distributions used in modeling extreme value problems. This class includes the Gumbel and Frechet distributions. The probability density for the Weibull distribution is  \[p(x) = \frac{a} {\lambda}(\frac{x}{\lambda})^{a-1}e^{-(x/\lambda)^a},\] where \(a\) is the shape and \(\lambda\) the scale. The function has its peak (the mode) at \(\lambda(\frac{a-1}{a})^{1/a}\). When a = 1, the Weibull distribution reduces to the exponential distribution. References  1 
Waloddi Weibull, Royal Technical University, Stockholm, 1939 “A Statistical Theory Of The Strength Of Materials”, Ingeniorsvetenskapsakademiens Handlingar Nr 151, 1939, Generalstabens Litografiska Anstalts Forlag, Stockholm.  2 
Waloddi Weibull, “A Statistical Distribution Function of Wide Applicability”, Journal Of Applied Mechanics ASME Paper 1951.  3 
Wikipedia, “Weibull distribution”, https://en.wikipedia.org/wiki/Weibull_distribution   Examples Draw samples from the distribution: >>> rng = np.random.default_rng()
>>> a = 5. # shape
>>> s = rng.weibull(a, 1000)
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> x = np.arange(1,100.)/50.
>>> def weib(x,n,a):
...     return (a / n) * (x / n)**(a - 1) * np.exp(-(x / n)**a)
 >>> count, bins, ignored = plt.hist(rng.weibull(5.,1000))
>>> x = np.arange(1,100.)/50.
>>> scale = count.max()/weib(x, 1., 5.).max()
>>> plt.plot(x, weib(x, 1., 5.)*scale)
>>> plt.show()
numpy.random.Generator.zipf method   random.Generator.zipf(a, size=None)
 
Draw samples from a Zipf distribution. Samples are drawn from a Zipf distribution with specified parameter a > 1. The Zipf distribution (also known as the zeta distribution) is a discrete probability distribution that satisfies Zipf’s law: the frequency of an item is inversely proportional to its rank in a frequency table.  Parameters 
 
afloat or array_like of floats


Distribution parameter. Must be greater than 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 a is a scalar. Otherwise, np.array(a).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized Zipf distribution.      See also  scipy.stats.zipf

probability density function, distribution, or cumulative density function, etc.    Notes The probability density for the Zipf distribution is  \[p(k) = \frac{k^{-a}}{\zeta(a)},\] for integers \(k \geq 1\), where \(\zeta\) is the Riemann Zeta function. It is named for the American linguist George Kingsley Zipf, who noted that the frequency of any word in a sample of a language is inversely proportional to its rank in the frequency table. References  1 
Zipf, G. K., “Selected Studies of the Principle of Relative Frequency in Language,” Cambridge, MA: Harvard Univ. Press, 1932.   Examples Draw samples from the distribution: >>> a = 4.0
>>> n = 20000
>>> s = np.random.default_rng().zipf(a, size=n)
 Display the histogram of the samples, along with the expected histogram based on the probability density function: >>> import matplotlib.pyplot as plt
>>> from scipy.special import zeta  
 bincount provides a fast histogram for small integers. >>> count = np.bincount(s)
>>> k = np.arange(1, s.max() + 1)
 >>> plt.bar(k, count[1:], alpha=0.5, label='sample count')
>>> plt.plot(k, n*(k**-a)/zeta(a), 'k.-', alpha=0.5,
...          label='expected count')   
>>> plt.semilogy()
>>> plt.grid(alpha=0.4)
>>> plt.legend()
>>> plt.title(f'Zipf sample, a={a}, size={n}')
>>> plt.show()
numpy.random.geometric   random.geometric(p, size=None)
 
Draw samples from the geometric distribution. Bernoulli trials are experiments with one of two outcomes: success or failure (an example of such an experiment is flipping a coin). The geometric distribution models the number of trials that must be run in order to achieve success. It is therefore supported on the positive integers, k = 1, 2, .... The probability mass function of the geometric distribution is  \[f(k) = (1 - p)^{k - 1} p\] where p is the probability of success of an individual trial.  Note New code should use the geometric method of a default_rng() instance instead; please see the Quick Start.   Parameters 
 
pfloat or array_like of floats


The probability of success of an individual trial.  
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 geometric distribution.      See also  Generator.geometric

which should be used for new code.    Examples Draw ten thousand values from the geometric distribution, with the probability of an individual success equal to 0.35: >>> z = np.random.geometric(p=0.35, size=10000)
 How many trials succeeded after a single run? >>> (z == 1).sum() / 10000.
0.34889999999999999 #random
numpy.random.get_state   random.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.laplace   random.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.logistic   random.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.logseries   random.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.MT19937.cffi attribute   random.MT19937.cffi
 
CFFI interface  Returns 
 
interfacenamedtuple


Named tuple containing CFFI wrapper  state_address - Memory address of the state struct state - pointer to the state struct next_uint64 - function pointer to produce 64 bit integers next_uint32 - function pointer to produce 32 bit integers next_double - function pointer to produce doubles bitgen - pointer to the bit generator struct
numpy.random.MT19937.ctypes attribute   random.MT19937.ctypes
 
ctypes interface  Returns 
 
interfacenamedtuple


Named tuple containing ctypes wrapper  state_address - Memory address of the state struct state - pointer to the state struct next_uint64 - function pointer to produce 64 bit integers next_uint32 - function pointer to produce 32 bit integers next_double - function pointer to produce doubles bitgen - pointer to the bit generator struct
numpy.random.MT19937.jumped method   random.MT19937.jumped(jumps=1)
 
Returns a new bit generator with the state jumped The state of the returned big generator is jumped as-if 2**(128 * jumps) random numbers have been generated.  Parameters 
 
jumpsinteger, positive


Number of times to jump the state of the bit generator returned    Returns 
 
bit_generatorMT19937


New instance of generator jumped iter times     Notes The jump step is computed using a modified version of Matsumoto’s implementation of Horner’s method. The step polynomial is precomputed to perform 2**128 steps. The jumped state has been verified to match the state produced using Matsumoto’s original code. References  1 
Matsumoto, M, Generating multiple disjoint streams of pseudorandom number sequences. Accessed on: May 6, 2020. http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/JUMP/  2 
Hiroshi Haramoto, Makoto Matsumoto, Takuji Nishimura, François Panneton, Pierre L’Ecuyer, “Efficient Jump Ahead for F2-Linear Random Number Generators”, INFORMS JOURNAL ON COMPUTING, Vol. 20, No. 3, Summer 2008, pp. 385-390.
numpy.random.MT19937.state attribute   random.MT19937.state
 
Get or set the PRNG state  Returns 
 
statedict


Dictionary containing the information required to describe the state of the PRNG
numpy.random.multinomial   random.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.negative_binomial   random.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.noncentral_chisquare   random.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()