summaryrefslogtreecommitdiff
path: root/numpy/lib/polynomial.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/polynomial.py')
-rw-r--r--numpy/lib/polynomial.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index 0fd9bbd79..23021cafa 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -489,16 +489,19 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False):
default) just the coefficients are returned, when True diagnostic
information from the singular value decomposition is also returned.
w : array_like, shape (M,), optional
- Weights to apply to the y-coordinates of the sample points. For
- gaussian uncertainties, use 1/sigma (not 1/sigma**2).
+ Weights. If not None, the weight ``w[i]`` applies to the unsquared
+ residual ``y[i] - y_hat[i]`` at ``x[i]``. Ideally the weights are
+ chosen so that the errors of the products ``w[i]*y[i]`` all have the
+ same variance. When using inverse-variance weighting, use
+ ``w[i] = 1/sigma(y[i])``. The default value is None.
cov : bool or str, optional
If given and not `False`, return not just the estimate but also its
covariance matrix. By default, the covariance are scaled by
- chi2/dof, where dof = M - (deg + 1), i.e., the weights are presumed
- to be unreliable except in a relative sense and everything is scaled
- such that the reduced chi2 is unity. This scaling is omitted if
- ``cov='unscaled'``, as is relevant for the case that the weights are
- 1/sigma**2, with sigma known to be a reliable estimate of the
+ chi2/dof, where dof = M - (deg + 1), i.e., the weights are presumed
+ to be unreliable except in a relative sense and everything is scaled
+ such that the reduced chi2 is unity. This scaling is omitted if
+ ``cov='unscaled'``, as is relevant for the case that the weights are
+ w = 1/sigma, with sigma known to be a reliable estimate of the
uncertainty.
Returns
@@ -708,8 +711,8 @@ def polyval(p, x):
``p[0]*x**(N-1) + p[1]*x**(N-2) + ... + p[N-2]*x + p[N-1]``
- If `x` is a sequence, then `p(x)` is returned for each element of `x`.
- If `x` is another polynomial then the composite polynomial `p(x(t))`
+ If `x` is a sequence, then ``p(x)`` is returned for each element of ``x``.
+ If `x` is another polynomial then the composite polynomial ``p(x(t))``
is returned.
Parameters
@@ -1037,7 +1040,7 @@ def polydiv(u, v):
return poly1d(q), poly1d(r)
return q, r
-_poly_mat = re.compile(r"[*][*]([0-9]*)")
+_poly_mat = re.compile(r"\*\*([0-9]*)")
def _raise_power(astr, wrap=70):
n = 0
line1 = ''
@@ -1394,9 +1397,9 @@ class poly1d:
def __getitem__(self, val):
ind = self.order - val
if val > self.order:
- return 0
+ return self.coeffs.dtype.type(0)
if val < 0:
- return 0
+ return self.coeffs.dtype.type(0)
return self.coeffs[ind]
def __setitem__(self, key, val):