scipy 1.8.0 Pypi GitHub Homepage
Other Docs
AttributesMethodsNotesParametersBackRef

Attributes

fill_value :

x and y are arrays of values used to approximate some function f: y = f(x) . This class returns a function whose call method uses interpolation to find the value of new points.

Methods

Notes

Calling interp1d with NaNs present in input values results in undefined behaviour.

Input values x and y must be convertible to :None:None:`float` values like :None:None:`int` or :None:None:`float`.

If the values in x are not unique, the resulting behavior is undefined and specific to the choice of :None:None:`kind`, i.e., changing :None:None:`kind` will change the behavior for duplicates.

Parameters

x : (N,) array_like

A 1-D array of real values.

y : (...,N,...) array_like

A N-D array of real values. The length of y along the interpolation axis must be equal to the length of x.

kind : str or int, optional

Specifies the kind of interpolation as a string or as an integer specifying the order of the spline interpolator to use. The string has to be one of 'linear', 'nearest', 'nearest-up', 'zero', 'slinear', 'quadratic', 'cubic', 'previous', or 'next'. 'zero', 'slinear', 'quadratic' and 'cubic' refer to a spline interpolation of zeroth, first, second or third order; 'previous' and 'next' simply return the previous or next value of the point; 'nearest-up' and 'nearest' differ when interpolating half-integers (e.g. 0.5, 1.5) in that 'nearest-up' rounds up and 'nearest' rounds down. Default is 'linear'.

axis : int, optional

Specifies the axis of y along which to interpolate. Interpolation defaults to the last axis of y.

copy : bool, optional

If True, the class makes internal copies of x and y. If False, references to x and y are used. The default is to copy.

bounds_error : bool, optional

If True, a ValueError is raised any time interpolation is attempted on a value outside of the range of x (where extrapolation is necessary). If False, out of bounds values are assigned :None:None:`fill_value`. By default, an error is raised unless fill_value="extrapolate" .

fill_value : array-like or (array-like, array_like) or "extrapolate", optional
  • if a ndarray (or float), this value will be used to fill in for requested points outside of the data range. If not provided, then the default is NaN. The array-like must broadcast properly to the dimensions of the non-interpolation axes.

  • If a two-element tuple, then the first element is used as a fill value for x_new < x[0] and the second element is used for x_new > x[-1] . Anything that is not a 2-element tuple (e.g., list or ndarray, regardless of shape) is taken to be a single array-like argument meant to be used for both bounds as below, above = fill_value, fill_value . Using a two-element tuple or ndarray requires bounds_error=False .

    versionadded
  • If "extrapolate", then points outside the data range will be extrapolated.

    versionadded
assume_sorted : bool, optional

If False, values of x can be in any order and they are sorted first. If True, x has to be an array of monotonically increasing values.

Interpolate a 1-D function.

See Also

UnivariateSpline

An object-oriented wrapper of the FITPACK routines.

interp2d

2-D interpolation

splev

Spline interpolation/smoothing based on FITPACK.

splrep

Spline interpolation/smoothing based on FITPACK.

Examples

>>> import matplotlib.pyplot as plt
... from scipy import interpolate
... x = np.arange(0, 10)
... y = np.exp(-x/3.0)
... f = interpolate.interp1d(x, y)
>>> xnew = np.arange(0, 9, 0.1)
... ynew = f(xnew) # use interpolation function returned by `interp1d`
... plt.plot(x, y, 'o', xnew, ynew, '-')
... plt.show()
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.signal.windows._windows.dpss scipy.interpolate._interpolate.interp2d pandas.core.generic.NDFrame.interpolate scipy.interpolate._interpolate.interp1d

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/interpolate/_interpolate.py#341
type: <class 'type'>
Commit: