

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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?
<p>The <strong><em>scipy.interpolate.interp1d(x, y, kind, axis, copy, bounds_error, fill_value, assumesorted)</em></strong> 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.</p><p>Below is given the detailed explanation of its parameters −</p><h2>Parameters</h2><ul class="list"><li><strong>x − (N,) <em>array_like</em></strong><p>It is a 1-dimensional array of real values.</p></li><li><p><strong>y − (…,N,…) <em>array_like</em></strong></p><p>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.</p></li><li><p><strong>kind − <em>str or int, optional</em></strong></p></li></ul><p>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 −</p><ul class="list"><li><p>linear</p></li><li><p>nearest</p></li><li><p>nearest-up</p></li><li><p>zero</p></li><li><p>slinear</p></li><li><p>quadratic</p></li><li><p>cubic</p></li><li><p>previous</p></li><li><p>next</p></li></ul><p>The default value of this parameter is ‘linear’.</p><ul class="list"><li><p><strong>axis − <em>int, optional</em></strong></p><p>As name implies, this parameter specifies the axis of y along which we need to interpolate.</p></li><li><p><strong>copy − <em>bool, optional</em></strong></p><p>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’.</p></li><li><p><strong>bounds_error − <em>bool, optional</em></strong></p><p>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”.</p></li><li><strong>fill_value − <em>array-like or (array-like, array_like) or “extrapolate”, optional</em></strong></li></ul><p>There are following three cases for fill_value parameter−</p><ul class="list"><li><p><strong>ndarray or float</strong>− 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.</p></li><li><p><strong>Two-element tuple</strong>− 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[0]. The second element will be used for x_new > x[-1].</p></li><li><p><strong>Extrapolate</strong>− If we provide ‘extrapolate’, the points outside the range of data will be generalized or extrapolated.</p></li><li><strong>assume_sorted − <em>bool, optional</em></strong><p>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.</p></li></ul>
- Related Questions & Answers
- What are various sub-packages in Python SciPy library?
- Finding determinant of a square matrix using SciPy library
- Finding inverse of a square matrix using SciPy library
- What is interpolation and how can we implement it in the SciPy Python library?
- What is SciPy and why should we use it?
- Implementing K-means clustering of Diabetes dataset with SciPy library
- How can we use the SciPy library to solve a Linear equation?
- What is the difference between SciPy and NumPy?
- How can we use various mathematical and physical constants in 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
- SciPy is built upon which core packages?
- Which linear function of SciPy is used to solve the circulant matrix equation?
Advertisements