- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the use of scipy.interpolate.interp1d class of SciPy python library?
The scipy.interpolate.interp1d(x, y, kind, axis, copy, bounds_error, fill_value, assumesorted) class of SciPy library, as name implies, is used to interpolate a 1-Dimensional function. Here, x and y are the arrays of values which are used to approximate some function, say f; y=f(x). The output of this class is a function whose call method uses interpolation to find the value of new points.
Below is given the detailed explanation of its parameters −
- x − (N,) array_like
It is a 1-dimensional array of real values.
y − (…,N,…) array_like
It is a N-dimensional array of real values. The condition is that the length of y along with the interpolation axis should be equal to the length of x.
kind − str or int, optional
As name implies, this parameter specifies the kind of interpolation. It can of string or integer. If you are going to provide string, then it must be one of the following −
The default value of this parameter is ‘linear’.
axis − int, optional
As name implies, this parameter specifies the axis of y along which we need to interpolate.
copy − bool, optional
This parameter, if true, is used to make the internal copies of x and y. On the other hand, if the value of this parameter is false, the references of x and y are used. The default value of this parameter is ‘True’.
bounds_error − bool, optional
This parameter, if true, is used to raise a ValueError on attempting interpolation on a value outside the range of x. and y. On the other hand, if the value of this parameter is false, out of bounds values are assigned fill_value. By default, this parameter will raise an error unless fill_value = “extrapolate”.
- fill_value − array-like or (array-like, array_like) or “extrapolate”, optional
There are following three cases for fill_value parameter−
ndarray or float− If this would be a ndarry or float then the value will be used to fill in for requested points outside of the range of data. The default value is NaN.
Two-element tuple− If this would be a two-element tuple, both elements will be used in different ways. The first element will be used as a fill value for x_new < x. The second element will be used for x_new > x[-1].
Extrapolate− If we provide ‘extrapolate’, the points outside the range of data will be generalized or extrapolated.
- assume_sorted − bool, optional
If the value of this parameter is true, the values of x should be an array of monotonically increasing values. On the other hand, if the value of this parameter is false, the values of x can be in any order and the values will be sorted first as well.
- Related Articles
- What are various sub-packages in Python SciPy library?
- What is interpolation and how can we implement it in the SciPy Python library?
- Finding determinant of a square matrix using SciPy library
- Finding inverse of a square matrix using SciPy library
- How can we use the SciPy library to solve a Linear equation?
- Implementing K-means clustering of Diabetes dataset with SciPy library
- What is SciPy and why should we use it?
- How can we use various mathematical and physical constants in scipy library?
- What is the difference between SciPy and NumPy?
- How to implement ‘cubic’ 1-D interpolation using SciPy library?
- Comparing ‘cubic’ and ‘linear’ 1-D interpolation using SciPy library
- How do I install Python SciPy?
- Calculating the Manhattan distance using SciPy
- Calculating the Minkowski distance using SciPy
- Calculating the Hamming distance using SciPy