neulab/docprompting-conala huggingface dataset:
numpy.polynomial.polyutils.mapdomain   polynomial.polyutils.mapdomain(x, old, new)[source]
 
Apply linear map to input points. The linear map offset + scale*x that maps the domain old to the domain new is applied to the points x.  Parameters 
 
xarray_like


Points to be mapped. If x is a subtype of ndarray the subtype will be preserved.  
old, newarray_like


The two domains that determine the map. Each must (successfully) convert to 1-d arrays containing precisely two values.    Returns 
 
x_outndarray


Array of points of the same shape as x, after application of the linear map between the two domains.      See also  
getdomain, mapparms

  Notes Effectively, this implements:  \[x\_out = new[0] + m(x - old[0])\] where  \[m = \frac{new[1]-new[0]}{old[1]-old[0]}\] Examples >>> from numpy.polynomial import polyutils as pu
>>> old_domain = (-1,1)
>>> new_domain = (0,2*np.pi)
>>> x = np.linspace(-1,1,6); x
array([-1. , -0.6, -0.2,  0.2,  0.6,  1. ])
>>> x_out = pu.mapdomain(x, old_domain, new_domain); x_out
array([ 0.        ,  1.25663706,  2.51327412,  3.76991118,  5.02654825, # may vary
        6.28318531])
>>> x - pu.mapdomain(x_out, new_domain, old_domain)
array([0., 0., 0., 0., 0., 0.])
 Also works for complex numbers (and thus can be used to map any line in the complex plane to any other line therein). >>> i = complex(0,1)
>>> old = (-1 - i, 1 + i)
>>> new = (-1 + i, 1 - i)
>>> z = np.linspace(old[0], old[1], 6); z
array([-1. -1.j , -0.6-0.6j, -0.2-0.2j,  0.2+0.2j,  0.6+0.6j,  1. +1.j ])
>>> new_z = pu.mapdomain(z, old, new); new_z
array([-1.0+1.j , -0.6+0.6j, -0.2+0.2j,  0.2-0.2j,  0.6-0.6j,  1.0-1.j ]) # may vary
numpy.polynomial.polyutils.mapparms   polynomial.polyutils.mapparms(old, new)[source]
 
Linear map parameters between domains. Return the parameters of the linear map offset + scale*x that maps old to new such that old[i] -> new[i], i = 0, 1.  Parameters 
 
old, newarray_like


Domains. Each domain must (successfully) convert to a 1-d array containing precisely two values.    Returns 
 
offset, scalescalars


The map L(x) = offset + scale*x maps the first domain to the second.      See also  
getdomain, mapdomain

  Notes Also works for complex numbers, and thus can be used to calculate the parameters required to map any line in the complex plane to any other line therein. Examples >>> from numpy.polynomial import polyutils as pu
>>> pu.mapparms((-1,1),(-1,1))
(0.0, 1.0)
>>> pu.mapparms((1,-1),(-1,1))
(-0.0, -1.0)
>>> i = complex(0,1)
>>> pu.mapparms((-i,-1),(1,i))
((1+1j), (1-0j))
numpy.polynomial.polyutils.RankWarning   exception polynomial.polyutils.RankWarning[source]
 
Issued by chebfit when the design matrix is rank deficient.
numpy.polynomial.polyutils.trimcoef   polynomial.polyutils.trimcoef(c, tol=0)[source]
 
Remove “small” “trailing” coefficients from a polynomial. “Small” means “small in absolute value” and is controlled by the parameter tol; “trailing” means highest order coefficient(s), e.g., in [0, 1, 1, 0, 0] (which represents 0 + x + x**2 + 0*x**3 + 0*x**4) both the 3-rd and 4-th order coefficients would be “trimmed.”  Parameters 
 
carray_like


1-d array of coefficients, ordered from lowest order to highest.  
tolnumber, optional


Trailing (i.e., highest order) elements with absolute value less than or equal to tol (default value is zero) are removed.    Returns 
 
trimmedndarray


1-d array with trailing zeros removed. If the resulting series would be empty, a series containing a single zero is returned.    Raises 
 ValueError

If tol < 0      See also  trimseq
  Examples >>> from numpy.polynomial import polyutils as pu
>>> pu.trimcoef((0,0,3,0,5,0,0))
array([0.,  0.,  3.,  0.,  5.])
>>> pu.trimcoef((0,0,1e-3,0,1e-5,0,0),1e-3) # item == tol is trimmed
array([0.])
>>> i = complex(0,1) # works for complex
>>> pu.trimcoef((3e-4,1e-3*(1-i),5e-4,2e-5*(1+i)), 1e-3)
array([0.0003+0.j   , 0.001 -0.001j])
numpy.polynomial.polyutils.trimseq   polynomial.polyutils.trimseq(seq)[source]
 
Remove small Poly series coefficients.  Parameters 
 
seqsequence


Sequence of Poly series coefficients. This routine fails for empty sequences.    Returns 
 
seriessequence


Subsequence with trailing zeros removed. If the resulting sequence would be empty, return the first element. The returned sequence may or may not be a view.     Notes Do not lose the type info if the sequence contains unknown objects.
numpy.polynomial.set_default_printstyle   polynomial.set_default_printstyle(style)[source]
 
Set the default format for the string representation of polynomials. Values for style must be valid inputs to __format__, i.e. ‘ascii’ or ‘unicode’.  Parameters 
 
stylestr


Format string for default printing style. Must be either ‘ascii’ or ‘unicode’.     Notes The default format depends on the platform: ‘unicode’ is used on Unix-based systems and ‘ascii’ on Windows. This determination is based on default font support for the unicode superscript and subscript ranges. Examples >>> p = np.polynomial.Polynomial([1, 2, 3])
>>> c = np.polynomial.Chebyshev([1, 2, 3])
>>> np.polynomial.set_default_printstyle('unicode')
>>> print(p)
1.0 + 2.0·x¹ + 3.0·x²
>>> print(c)
1.0 + 2.0·T₁(x) + 3.0·T₂(x)
>>> np.polynomial.set_default_printstyle('ascii')
>>> print(p)
1.0 + 2.0 x**1 + 3.0 x**2
>>> print(c)
1.0 + 2.0 T_1(x) + 3.0 T_2(x)
>>> # Formatting supersedes all class/package-level defaults
>>> print(f"{p:unicode}")
1.0 + 2.0·x¹ + 3.0·x²
Polyutils Utility classes and functions for the polynomial modules. This module provides: error and warning objects; a polynomial base class; and some routines used in both the polynomial and chebyshev modules.  Warning objects  
RankWarning Issued by chebfit when the design matrix is rank deficient.     Functions  
as_series(alist[, trim]) Return argument as a list of 1-d arrays.  
trimseq(seq) Remove small Poly series coefficients.  
trimcoef(c[, tol]) Remove "small" "trailing" coefficients from a polynomial.  
getdomain(x) Return a domain suitable for given abscissae.  
mapdomain(x, old, new) Apply linear map to input points.  
mapparms(old, new) Linear map parameters between domains.
numpy.random.beta   random.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.binomial   random.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.BitGenerator.cffi attribute   random.BitGenerator.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.BitGenerator.random_raw method   random.BitGenerator.random_raw(self, size=None)
 
Return randoms as generated by the underlying BitGenerator  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.  
outputbool, optional


Output values. Used for performance testing since the generated values are not returned.    Returns 
 
outuint or ndarray


Drawn samples.     Notes This method directly exposes the the raw underlying pseudo-random number generator. All values are returned as unsigned 64-bit values irrespective of the number of bits produced by the PRNG. See the class docstring for the number of bits returned.
numpy.random.bytes   random.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.chisquare   random.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.choice   random.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.dirichlet   random.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.exponential   random.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.f   random.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.