neulab/docprompting-conala huggingface dataset:
numpy.random.gamma   random.gamma(shape, scale=1.0, size=None)
 
Draw samples from a Gamma distribution. Samples are drawn from a Gamma distribution with specified parameters, shape (sometimes designated “k”) and scale (sometimes designated “theta”), where both parameters are > 0.  Note New code should use the gamma method of a default_rng() instance instead; please see the Quick Start.   Parameters 
 
shapefloat or array_like of floats


The shape of the gamma distribution. Must be non-negative.  
scalefloat or array_like of floats, optional


The scale of the gamma distribution. Must be non-negative. Default is equal to 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 shape and scale are both scalars. Otherwise, np.broadcast(shape, scale).size samples are drawn.    Returns 
 
outndarray or scalar


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

probability density function, distribution or cumulative density function, etc.  Generator.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., 2.  # mean=4, std=2*sqrt(2)
>>> s = np.random.gamma(shape, scale, 1000)
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> import scipy.special as sps  
>>> count, bins, ignored = plt.hist(s, 50, density=True)
>>> y = bins**(shape-1)*(np.exp(-bins/scale) /  
...                      (sps.gamma(shape)*scale**shape))
>>> plt.plot(bins, y, linewidth=2, color='r')  
>>> plt.show()
numpy.random.Generator.beta method   random.Generator.beta(a, b, size=None)
 
Draw samples from a Beta distribution. The Beta distribution is a special case of the Dirichlet distribution, and is related to the Gamma distribution. It has the probability distribution function  \[f(x; a,b) = \frac{1}{B(\alpha, \beta)} x^{\alpha - 1} (1 - x)^{\beta - 1},\] where the normalization, B, is the beta function,  \[B(\alpha, \beta) = \int_0^1 t^{\alpha - 1} (1 - t)^{\beta - 1} dt.\] It is often seen in Bayesian inference and order statistics.  Parameters 
 
afloat or array_like of floats


Alpha, positive (>0).  
bfloat or array_like of floats


Beta, positive (>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 a and b are both scalars. Otherwise, np.broadcast(a, b).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized beta distribution.
numpy.random.Generator.binomial method   random.Generator.binomial(n, p, size=None)
 
Draw samples from a binomial distribution. Samples are drawn from a binomial distribution with specified parameters, n trials and p probability of success where n an integer >= 0 and p is in the interval [0,1]. (n may be input as a float, but it is truncated to an integer in use)  Parameters 
 
nint or array_like of ints


Parameter of the distribution, >= 0. Floats are also accepted, but they will be truncated to integers.  
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 binomial distribution, where each sample is equal to the number of successes over the n trials.      See also  scipy.stats.binom

probability density function, distribution or cumulative density function, etc.    Notes The probability density for the binomial distribution is  \[P(N) = \binom{n}{N}p^N(1-p)^{n-N},\] where \(n\) is the number of trials, \(p\) is the probability of success, and \(N\) is the number of successes. When estimating the standard error of a proportion in a population by using a random sample, the normal distribution works well unless the product p*n <=5, where p = population proportion estimate, and n = number of samples, in which case the binomial distribution is used instead. For example, a sample of 15 people shows 4 who are left handed, and 11 who are right handed. Then p = 4/15 = 27%. 0.27*15 = 4, so the binomial distribution should be used in this case. References  1 
Dalgaard, Peter, “Introductory Statistics with R”, Springer-Verlag, 2002.  2 
Glantz, Stanton A. “Primer of Biostatistics.”, McGraw-Hill, Fifth Edition, 2002.  3 
Lentner, Marvin, “Elementary Applied Statistics”, Bogden and Quigley, 1972.  4 
Weisstein, Eric W. “Binomial Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/BinomialDistribution.html  5 
Wikipedia, “Binomial distribution”, https://en.wikipedia.org/wiki/Binomial_distribution   Examples Draw samples from the distribution: >>> rng = np.random.default_rng()
>>> n, p = 10, .5  # number of trials, probability of each trial
>>> s = rng.binomial(n, p, 1000)
# result of flipping a coin 10 times, tested 1000 times.
 A real world example. A company drills 9 wild-cat oil exploration wells, each with an estimated probability of success of 0.1. All nine wells fail. What is the probability of that happening? Let’s do 20,000 trials of the model, and count the number that generate zero positive results. >>> sum(rng.binomial(9, 0.1, 20000) == 0)/20000.
# answer = 0.38885, or 39%.
numpy.random.Generator.bit_generator attribute   random.Generator.bit_generator
 
Gets the bit generator instance used by the generator  Returns 
 
bit_generatorBitGenerator


The bit generator instance used by the generator
numpy.random.Generator.bytes method   random.Generator.bytes(length)
 
Return random bytes.  Parameters 
 
lengthint


Number of random bytes.    Returns 
 
outbytes


String of length length.     Examples >>> np.random.default_rng().bytes(10)
b'\xfeC\x9b\x86\x17\xf2\xa1\xafcp' # random
numpy.random.Generator.chisquare method   random.Generator.chisquare(df, size=None)
 
Draw samples from a chi-square distribution. When df independent random variables, each with standard normal distributions (mean 0, variance 1), are squared and summed, the resulting distribution is chi-square (see Notes). This distribution is often used in hypothesis testing.  Parameters 
 
dffloat or array_like of floats


Number of degrees of freedom, 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 df is a scalar. Otherwise, np.array(df).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized chi-square distribution.    Raises 
 ValueError

When df <= 0 or when an inappropriate size (e.g. size=-1) is given.     Notes The variable obtained by summing the squares of df independent, standard normally distributed random variables:  \[Q = \sum_{i=0}^{\mathtt{df}} X^2_i\] is chi-square distributed, denoted  \[Q \sim \chi^2_k.\] The probability density function of the chi-squared distribution is  \[p(x) = \frac{(1/2)^{k/2}}{\Gamma(k/2)} x^{k/2 - 1} e^{-x/2},\] where \(\Gamma\) is the gamma function,  \[\Gamma(x) = \int_0^{-\infty} t^{x - 1} e^{-t} dt.\] References  1 
NIST “Engineering Statistics Handbook” https://www.itl.nist.gov/div898/handbook/eda/section3/eda3666.htm   Examples >>> np.random.default_rng().chisquare(2,4)
array([ 1.89920014,  9.00867716,  3.13710533,  5.62318272]) # random
numpy.random.Generator.choice method   random.Generator.choice(a, size=None, replace=True, p=None, axis=0, shuffle=True)
 
Generates a random sample from a given array  Parameters 
 
a{array_like, int}


If an ndarray, a random sample is generated from its elements. If an int, the random sample is generated from np.arange(a).  
size{int, tuple[int]}, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn from the 1-d a. If a has more than one dimension, the size shape will be inserted into the axis dimension, so the output ndim will be a.ndim - 1 +
len(size). Default is None, in which case a single value is returned.  
replacebool, optional


Whether the sample is with or without replacement. Default is True, meaning that a value of a can be selected multiple times.  
p1-D array_like, optional


The probabilities associated with each entry in a. If not given, the sample assumes a uniform distribution over all entries in a.  
axisint, optional


The axis along which the selection is performed. The default, 0, selects by row.  
shufflebool, optional


Whether the sample is shuffled when sampling without replacement. Default is True, False provides a speedup.    Returns 
 
samplessingle item or ndarray


The generated random samples    Raises 
 ValueError

If a is an int and less than zero, if p is not 1-dimensional, if a is array-like with a size 0, if p is not a vector of probabilities, if a and p have different lengths, or if replace=False and the sample size is greater than the population size.      See also  
integers, shuffle, permutation

  Notes Setting user-specified probabilities through p uses a more general but less efficient sampler than the default. The general sampler produces a different sample than the optimized sampler even if each element of p is 1 / len(a). Examples Generate a uniform random sample from np.arange(5) of size 3: >>> rng = np.random.default_rng()
>>> rng.choice(5, 3)
array([0, 3, 4]) # random
>>> #This is equivalent to rng.integers(0,5,3)
 Generate a non-uniform random sample from np.arange(5) of size 3: >>> rng.choice(5, 3, p=[0.1, 0, 0.3, 0.6, 0])
array([3, 3, 0]) # random
 Generate a uniform random sample from np.arange(5) of size 3 without replacement: >>> rng.choice(5, 3, replace=False)
array([3,1,0]) # random
>>> #This is equivalent to rng.permutation(np.arange(5))[:3]
 Generate a uniform random sample from a 2-D array along the first axis (the default), without replacement: >>> rng.choice([[0, 1, 2], [3, 4, 5], [6, 7, 8]], 2, replace=False)
array([[3, 4, 5], # random
       [0, 1, 2]])
 Generate a non-uniform random sample from np.arange(5) of size 3 without replacement: >>> rng.choice(5, 3, replace=False, p=[0.1, 0, 0.3, 0.6, 0])
array([2, 3, 0]) # random
 Any of the above can be repeated with an arbitrary array-like instead of just integers. For instance: >>> aa_milne_arr = ['pooh', 'rabbit', 'piglet', 'Christopher']
>>> rng.choice(aa_milne_arr, 5, p=[0.5, 0.1, 0.1, 0.3])
array(['pooh', 'pooh', 'pooh', 'Christopher', 'piglet'], # random
      dtype='<U11')
numpy.random.Generator.dirichlet method   random.Generator.dirichlet(alpha, size=None)
 
Draw samples from the Dirichlet distribution. Draw size samples of dimension k from a Dirichlet distribution. A Dirichlet-distributed random variable can be seen as a multivariate generalization of a Beta distribution. The Dirichlet distribution is a conjugate prior of a multinomial distribution in Bayesian inference.  Parameters 
 
alphasequence of floats, length k


Parameter of the distribution (length k for sample of length k).  
sizeint or tuple of ints, optional


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


The drawn samples, of shape (size, k).    Raises 
 ValueError

If any value in alpha is less than or equal to zero     Notes The Dirichlet distribution is a distribution over vectors \(x\) that fulfil the conditions \(x_i>0\) and \(\sum_{i=1}^k x_i = 1\). The probability density function \(p\) of a Dirichlet-distributed random vector \(X\) is proportional to  \[p(x) \propto \prod_{i=1}^{k}{x^{\alpha_i-1}_i},\] where \(\alpha\) is a vector containing the positive concentration parameters. The method uses the following property for computation: let \(Y\) be a random vector which has components that follow a standard gamma distribution, then \(X = \frac{1}{\sum_{i=1}^k{Y_i}} Y\) is Dirichlet-distributed References  1 
David McKay, “Information Theory, Inference and Learning Algorithms,” chapter 23, http://www.inference.org.uk/mackay/itila/  2 
Wikipedia, “Dirichlet distribution”, https://en.wikipedia.org/wiki/Dirichlet_distribution   Examples Taking an example cited in Wikipedia, this distribution can be used if one wanted to cut strings (each of initial length 1.0) into K pieces with different lengths, where each piece had, on average, a designated average length, but allowing some variation in the relative sizes of the pieces. >>> s = np.random.default_rng().dirichlet((10, 5, 3), 20).transpose()
 >>> import matplotlib.pyplot as plt
>>> plt.barh(range(20), s[0])
>>> plt.barh(range(20), s[1], left=s[0], color='g')
>>> plt.barh(range(20), s[2], left=s[0]+s[1], color='r')
>>> plt.title("Lengths of Strings")
numpy.random.Generator.exponential method   random.Generator.exponential(scale=1.0, size=None)
 
Draw samples from an exponential distribution. Its probability density function is  \[f(x; \frac{1}{\beta}) = \frac{1}{\beta} \exp(-\frac{x}{\beta}),\] for x > 0 and 0 elsewhere. \(\beta\) is the scale parameter, which is the inverse of the rate parameter \(\lambda = 1/\beta\). The rate parameter is an alternative, widely used parameterization of the exponential distribution [3]. The exponential distribution is a continuous analogue of the geometric distribution. It describes many common situations, such as the size of raindrops measured over many rainstorms [1], or the time between page requests to Wikipedia [2].  Parameters 
 
scalefloat or array_like of floats


The scale parameter, \(\beta = 1/\lambda\). 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 scale is a scalar. Otherwise, np.array(scale).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized exponential distribution.     References  1 
Peyton Z. Peebles Jr., “Probability, Random Variables and Random Signal Principles”, 4th ed, 2001, p. 57.  2 
Wikipedia, “Poisson process”, https://en.wikipedia.org/wiki/Poisson_process  3 
Wikipedia, “Exponential distribution”, https://en.wikipedia.org/wiki/Exponential_distribution
numpy.random.Generator.f method   random.Generator.f(dfnum, dfden, size=None)
 
Draw samples from an 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 must be greater than zero. The random variate of the F distribution (also known as the Fisher distribution) is a continuous probability distribution that arises in ANOVA tests, and is the ratio of two chi-square variates.  Parameters 
 
dfnumfloat or array_like of floats


Degrees of freedom in numerator, must be > 0.  
dfdenfloat or array_like of float


Degrees of freedom in denominator, 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 and dfden are both scalars. Otherwise, np.broadcast(dfnum, dfden).size samples are drawn.    Returns 
 
outndarray or scalar


Drawn samples from the parameterized Fisher distribution.      See also  scipy.stats.f

probability density function, distribution or cumulative density function, etc.    Notes The F statistic is used to compare in-group variances to between-group variances. Calculating the distribution depends on the sampling, and so it is a function of the respective degrees of freedom in the problem. The variable dfnum is the number of samples minus one, the between-groups degrees of freedom, while dfden is the within-groups degrees of freedom, the sum of the number of samples in each group minus the number of groups. References  1 
Glantz, Stanton A. “Primer of Biostatistics.”, McGraw-Hill, Fifth Edition, 2002.  2 
Wikipedia, “F-distribution”, https://en.wikipedia.org/wiki/F-distribution   Examples An example from Glantz[1], pp 47-40: Two groups, children of diabetics (25 people) and children from people without diabetes (25 controls). Fasting blood glucose was measured, case group had a mean value of 86.1, controls had a mean value of 82.2. Standard deviations were 2.09 and 2.49 respectively. Are these data consistent with the null hypothesis that the parents diabetic status does not affect their children’s blood glucose levels? Calculating the F statistic from the data gives a value of 36.01. Draw samples from the distribution: >>> dfnum = 1. # between group degrees of freedom
>>> dfden = 48. # within groups degrees of freedom
>>> s = np.random.default_rng().f(dfnum, dfden, 1000)
 The lower bound for the top 1% of the samples is : >>> np.sort(s)[-10]
7.61988120985 # random
 So there is about a 1% chance that the F statistic will exceed 7.62, the measured value is 36, so the null hypothesis is rejected at the 1% level.
numpy.random.Generator.gamma method   random.Generator.gamma(shape, scale=1.0, size=None)
 
Draw samples from a Gamma distribution. Samples are drawn from a Gamma distribution with specified parameters, shape (sometimes designated “k”) and scale (sometimes designated “theta”), where both parameters are > 0.  Parameters 
 
shapefloat or array_like of floats


The shape of the gamma distribution. Must be non-negative.  
scalefloat or array_like of floats, optional


The scale of the gamma distribution. Must be non-negative. Default is equal to 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 shape and scale are both scalars. Otherwise, np.broadcast(shape, scale).size samples are drawn.    Returns 
 
outndarray or scalar


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

probability density function, distribution or cumulative density function, etc.    Notes The probability density for the Gamma distribution is  \[p(x) = x^{k-1}\frac{e^{-x/\theta}}{\theta^k\Gamma(k)},\] where \(k\) is the shape and \(\theta\) the scale, and \(\Gamma\) is the Gamma function. The Gamma distribution is often used to model the times to failure of electronic components, and arises naturally in processes for which the waiting times between Poisson distributed events are relevant. References  1 
Weisstein, Eric W. “Gamma Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/GammaDistribution.html  2 
Wikipedia, “Gamma distribution”, https://en.wikipedia.org/wiki/Gamma_distribution   Examples Draw samples from the distribution: >>> shape, scale = 2., 2.  # mean=4, std=2*sqrt(2)
>>> s = np.random.default_rng().gamma(shape, scale, 1000)
 Display the histogram of the samples, along with the probability density function: >>> import matplotlib.pyplot as plt
>>> import scipy.special as sps  
>>> count, bins, ignored = plt.hist(s, 50, density=True)
>>> y = bins**(shape-1)*(np.exp(-bins/scale) /  
...                      (sps.gamma(shape)*scale**shape))
>>> plt.plot(bins, y, linewidth=2, color='r')  
>>> plt.show()
numpy.random.Generator.geometric method   random.Generator.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.  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.     Examples Draw ten thousand values from the geometric distribution, with the probability of an individual success equal to 0.35: >>> z = np.random.default_rng().geometric(p=0.35, size=10000)
 How many trials succeeded after a single run? >>> (z == 1).sum() / 10000.
0.34889999999999999 # random
numpy.random.Generator.integers method   random.Generator.integers(low, high=None, size=None, dtype=np.int64, endpoint=False)
 
Return random integers from low (inclusive) to high (exclusive), or if endpoint=True, low (inclusive) to high (inclusive). Replaces RandomState.randint (with endpoint=False) and RandomState.random_integers (with endpoint=True) Return random integers from the “discrete uniform” distribution of the specified dtype. If high is None (the default), then results are from 0 to low.  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 0 and this value is used for high).  
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 np.int64.  
endpointbool, optional


If true, sample from the interval [low, high] instead of the default [low, high) Defaults to False    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.     Notes When using broadcasting with uint64 dtypes, the maximum value (2**64) cannot be represented as a standard integer type. The high array (or low if high is None) must have object dtype, e.g., array([2**64]). References  1 
Daniel Lemire., “Fast Random Integer Generation in an Interval”, ACM Transactions on Modeling and Computer Simulation 29 (1), 2019, http://arxiv.org/abs/1805.10941.   Examples >>> rng = np.random.default_rng()
>>> rng.integers(2, size=10)
array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0])  # random
>>> rng.integers(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: >>> rng.integers(5, size=(2, 4))
array([[4, 0, 2, 1],
       [3, 2, 2, 0]])  # random
 Generate a 1 x 3 array with 3 different upper bounds >>> rng.integers(1, [3, 5, 10])
array([2, 2, 9])  # random
 Generate a 1 by 3 array with 3 different lower bounds >>> rng.integers([1, 5, 7], 10)
array([9, 8, 7])  # random
 Generate a 2 by 4 array using broadcasting with dtype of uint8 >>> rng.integers([1, 3, 5, 7], [[10], [20]], dtype=np.uint8)
array([[ 8,  6,  9,  7],
       [ 1, 16,  9, 12]], dtype=uint8)  # random