neulab/docprompting-conala huggingface dataset:
numpy.random.random_integers   random.random_integers(low, high=None, size=None)
 
Random integers of type np.int_ between low and high, inclusive. Return random integers of type np.int_ from the “discrete uniform” distribution in the closed interval [low, high]. If high is None (the default), then results are from [1, low]. The np.int_ type translates to the C long integer type and its precision is platform dependent. This function has been deprecated. Use randint instead.  Deprecated since version 1.11.0.   Parameters 
 
lowint


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


If provided, the largest (signed) integer to be drawn from the distribution (see above for behavior if high=None).  
sizeint or tuple of ints, optional


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.    Returns 
 
outint or ndarray of ints


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

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


Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.    Returns 
 
outfloat or ndarray of floats


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

which should be used for new code.    Examples >>> np.random.random_sample()
0.47108547995356098 # random
>>> type(np.random.random_sample())
<class 'float'>
>>> np.random.random_sample((5,))
array([ 0.30220482,  0.86820401,  0.1654503 ,  0.11659149,  0.54323428]) # random
 Three-by-two array of random numbers from [-5, 0): >>> 5 * np.random.random_sample((3, 2)) - 5
array([[-3.99149989, -0.52338984], # random
       [-2.99091858, -0.79479508],
       [-1.23204345, -1.75224494]])
numpy.random.RandomState.beta method   random.RandomState.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.  Note New code should use the beta method of a default_rng() instance instead; please see the Quick Start.   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.      See also  Generator.beta

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

which should be used for new code.    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: >>> n, p = 10, .5  # number of trials, probability of each trial
>>> s = np.random.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(np.random.binomial(9, 0.1, 20000) == 0)/20000.
# answer = 0.38885, or 38%.
numpy.random.RandomState.bytes method   random.RandomState.bytes(length)
 
Return random bytes.  Note New code should use the bytes method of a default_rng() instance instead; please see the Quick Start.   Parameters 
 
lengthint


Number of random bytes.    Returns 
 
outbytes


String of length length.      See also  Generator.bytes

which should be used for new code.    Examples >>> np.random.bytes(10)
b' eh\x85\x022SZ\xbf\xa4' #random
numpy.random.RandomState.chisquare method   random.RandomState.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.  Note New code should use the chisquare method of a default_rng() instance instead; please see the Quick Start.   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.      See also  Generator.chisquare

which should be used for new code.    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.chisquare(2,4)
array([ 1.89920014,  9.00867716,  3.13710533,  5.62318272]) # random
numpy.random.RandomState.choice method   random.RandomState.choice(a, size=None, replace=True, p=None)
 
Generates a random sample from a given 1-D array  New in version 1.7.0.   Note New code should use the choice method of a default_rng() instance instead; please see the Quick Start.   Parameters 
 
a1-D array-like or int


If an ndarray, a random sample is generated from its elements. If an int, the random sample is generated as if it were np.arange(a)  
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.  
replaceboolean, 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.    Returns 
 
samplessingle item or ndarray


The generated random samples    Raises 
 ValueError

If a is an int and less than zero, if a or p are not 1-dimensional, if a is an array-like of 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  
randint, shuffle, permutation

Generator.choice

which should be used in new code    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). Sampling random rows from a 2-D array is not possible with this function, but is possible with Generator.choice through its axis keyword. Examples Generate a uniform random sample from np.arange(5) of size 3: >>> np.random.choice(5, 3)
array([0, 3, 4]) # random
>>> #This is equivalent to np.random.randint(0,5,3)
 Generate a non-uniform random sample from np.arange(5) of size 3: >>> np.random.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: >>> np.random.choice(5, 3, replace=False)
array([3,1,0]) # random
>>> #This is equivalent to np.random.permutation(np.arange(5))[:3]
 Generate a non-uniform random sample from np.arange(5) of size 3 without replacement: >>> np.random.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']
>>> np.random.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.RandomState.dirichlet method   random.RandomState.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.  Note New code should use the dirichlet method of a default_rng() instance instead; please see the Quick Start.   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      See also  Generator.dirichlet

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

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

which should be used for new code.    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.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.RandomState.gamma method   random.RandomState.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.RandomState.geometric method   random.RandomState.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