
- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
SciPy - interpolate.Akima1DInterpolator() Function
scipy.interpolate.Akima1DInterpolator() is a function in Python's SciPy library for one-dimensional interpolation using Akima's piecewise cubic interpolation technique. It constructs a series of cubic polynomials that connect the data points while preserving the overall shape and characteristics of the original data.
This function is particularly effective for datasets with abrupt changes as it avoids overshooting and oscillations that can occur with traditional spline methods. The interpolator ensures that the resulting curve is smooth at the data points while being responsive to the local changes in the data by making it suitable for various applications in data analysis and visualization.
Syntax
Following is the syntax of the function scipy.interpolate.Akima1DInterpolator() to perform Akima's piecewise cubic interpolation −
Akima1DInterpolator(x, y, axis=0, extrapolate=None)
Parameters
Below are the parameters of the scipy.interpolate.Akima1DInterpolator() function −
- x: A 1D array-like input representing the x-coordinates of the data points. It must be sorted in increasing order.
- y: A 1D array-like input representing the corresponding y-coordinates. The length of y must match the length of x.
- axis(optional): An integer specifying the axis of the input data along which to interpolate. The default value is 0 which applies to the first axis.
- method (optional): A string specifying the interpolation method. By default it's set to 'akima' indicating the use of Akima's method. Other methods may be specified if available.
- extrapolate(optional): A boolean or a string that determines whether to allow extrapolation. If set to True then the interpolator will perform extrapolation outside the bounds of the input data. If set to False then it will raise an error for values outside the range of x. A string can specify a specific extrapolation method.
Return Value
The scipy.interpolate.Akima1DInterpolator() function returns an interpolator object that can be used to compute interpolated values at any desired x-coordinates within or outside the range of the input data.
Basic Akima Interpolation
Here's a basic example of using Akima1DInterpolator() for interpolation in Python. This example illustrates how to create an Akima interpolator and visualize the results −
import numpy as np from scipy.interpolate import Akima1DInterpolator import matplotlib.pyplot as plt # Sample data points (x and y) x = np.array([0, 1, 2, 3, 4, 5]) y = np.array([0, 1, 0, 1, 0, 1]) # Create the Akima interpolator akima_interpolator = Akima1DInterpolator(x, y) # Define new x values for interpolation x_new = np.linspace(0, 5, 100) y_new = akima_interpolator(x_new) # Plot the original data points and the interpolated curve plt.figure(figsize=(10, 6)) plt.plot(x, y, 'o', label='Original Data', markersize=8) plt.plot(x_new, y_new, label='Akima Interpolation', color='orange') plt.title('Basic Akima Interpolation Example') plt.xlabel('x') plt.ylabel('y') plt.legend() plt.grid() plt.show()
Here is the output of the scipy.interpolate.Akima1DInterpolator() function −

Extrapolation with Akima Interpolation
Extrapolation with Akima1DInterpolator() function allows us to estimate values outside the range of our input data. By default the Akima interpolation does not perform extrapolation unless specified. We can enable it using the extrapolate parameter when creating the interpolator. Here is the example −
import numpy as np from scipy.interpolate import Akima1DInterpolator import matplotlib.pyplot as plt # Sample data points x = np.array([0, 1, 2, 3, 4]) y = np.array([0, 1, 0, 1, 0]) # Create the Akima interpolator with extrapolation akima = Akima1DInterpolator(x, y, extrapolate=True) # Define new x values for interpolation (including extrapolation points) x_new = np.linspace(-1, 5, 100) # Includes values outside original x range y_new = akima(x_new) # Plot the results plt.plot(x, y, 'o', label='Original data') plt.plot(x_new, y_new, label='Akima Interpolation with Extrapolation', color='orange') plt.title('Akima 1D Interpolation with Extrapolation') plt.legend() plt.grid() plt.show()
Here is the output of the scipy.interpolate.Akima1DInterpolator() function used to perform Extrapolation −

Interpolating Noisy Data
Interpolating noisy data can be challenging because noise can distort the underlying trends. Using Akima1DInterpolator() function can help to create a smooth approximation of the data while maintaining the overall shape. Heres an example of how to interpolate a noisy dataset using Akima interpolation. −
import numpy as np from scipy.interpolate import Akima1DInterpolator import matplotlib.pyplot as plt # Original data points (with noise) x = np.linspace(0, 10, 10) y = np.sin(x) + np.random.normal(0, 0.1, x.shape) # Add noise # Create the Akima interpolator akima = Akima1DInterpolator(x, y) # Define new x values for interpolation x_new = np.linspace(0, 10, 100) y_new = akima(x_new) # Plot the noisy data and the interpolation plt.plot(x, y, 'o', label='Noisy data') plt.plot(x_new, y_new, label='Akima Interpolation', color='orange') plt.title('Akima Interpolation on Noisy Data') plt.legend() plt.grid() plt.show()
Here is the output of the scipy.interpolate.Akima1DInterpolator() function working with Noisy data−
