
- 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 - integrate.cumulative_simpson() Method
The SciPy integrate.cumulative_simpson() method is used to calculate the coordinates at every pairs by considering the quadratic relationship between an individual point and two adjacent points.
Syntax
Following is the syntax of the SciPy integrate.cumulative_simpson() method −
cumulative_simpson(var1, var2) or, cumulative_simpson(var1, var2, sample_point)
Parameters
This method accepts the following parameter −
- var1: This parameter is used to represent the various built-in function such as linspace(), sin() etc.
- var2: This parameter represent the simple mathematical calculation.
- sample_point: This is an optional poarameter required for coordinates/sample point.
Return value
This method returns the result in two different forms which are list of values and matplotlib graph.
Example 1
Following is the basic example that demonstrates the usage of SciPy integrate.cumulative_simpson() method.
from scipy import integrate import numpy as np import matplotlib.pyplot as plt x = np.linspace(-2, 2, num=10) y = x**2 y_int = integrate.cumulative_simpson(y, x=x, initial=0) fig, ax = plt.subplots() ax.plot(x, y_int, 'go', x, x**3/3 - (x[0])**3/3, 'b-') ax.grid() plt.show()
Output
The above code produces the following result −
Example 2
The program uses sin() function to calculate the sample(coords) point over the interval of 0 and 2pi where space between two point set at 0.1. After using the cumulative_simpson() method, the result is stored as a list.
import numpy as np from scipy.integrate import cumulative_simpson # declare y and dx values y = np.sin(np.linspace(0, 2 * np.pi, 50)) dx = 0.1 # spacing between element of y # operation on cumulative integral cum_integral = cumulative_simpson(y, dx=dx) print(cum_integral)
Output
The above code produces the following result −
[ 6.41135591e-03 2.55054410e-02 5.70028694e-02 1.00353446e-01 1.54876692e-01 2.19648187e-01 2.93630869e-01 3.75586562e-01 4.64189453e-01 5.57968599e-01 6.55396160e-01 7.54864639e-01 8.54744106e-01 9.53395658e-01 1.04919389e+00 1.14057569e+00 1.22602649e+00 1.30416123e+00 1.37367525e+00 1.43345212e+00 1.48248242e+00 1.51999138e+00 1.54533088e+00 1.55811848e+00 1.55810972e+00 1.54533951e+00 1.51998305e+00 1.48249033e+00 1.43344475e+00 1.37368194e+00 1.30415533e+00 1.22603152e+00 1.14057163e+00 1.04919692e+00 9.53393703e-01 8.54744950e-01 7.54864920e-01 6.55394758e-01 5.57971098e-01 4.64185897e-01 3.75591116e-01 2.93625392e-01 2.19654498e-01 1.54869651e-01 1.00361101e-01 5.69947265e-02 2.55139387e-02 6.40264306e-03 -8.71285215e-06]