Fact-checked by Grok 2 weeks ago

SciPy

SciPy is an open-source Python library designed for scientific and technical computing, extending the capabilities of NumPy by providing a collection of algorithms and functions for mathematics, science, and engineering. It includes modules for optimization, integration, interpolation, eigenvalue problems, algebraic equations, differential equations, signal and image processing, statistics, and spatial algorithms, among others, enabling efficient handling of complex numerical tasks through high-performance implementations in Fortran, C, and C++. Pronounced "Sigh Pie," SciPy features user-friendly high-level syntax and specialized data structures like sparse matrices and k-dimensional trees, making it a foundational tool for researchers and engineers worldwide. Originating in 2001 from efforts by developers , Eric Jones, and Pearu Peterson, SciPy emerged as a merger of numerical modules built on the Numeric package, addressing the need for advanced scientific in . Its development closely intertwined with , which unified the competing Numeric and Numarray libraries in 2005 under Oliphant's leadership, allowing SciPy to leverage a robust, flexible foundation. Key milestones include the first release in 2001, the transition to in 2005, the introduction of scikits for modular extensions in 2007, adoption of for development in 2011, and the stable SciPy 1.0 version in 2017 after 16 years of iterative improvements. Today, SciPy comprises 16 subpackages with over 1,000,000 lines of code, supports 3.11–3.14 as of version 1.16.3 (October 2025), and is licensed under the BSD terms, fostering a vibrant open-source community of over 1,000 contributors. SciPy's impact extends beyond core functionality, serving as a de facto standard for scientific algorithms in and underpinning libraries like for ; it has garnered approximately 200 million downloads annually and over 10,000 citations across key publications since , powering applications from detection to astrophysical imaging. Its emphasis on reliability, performance, and interoperability with other tools, including recent enhancements for the Python array standard, ensures it remains essential for reproducible research and production pipelines in diverse fields.

Introduction

Definition and Scope

SciPy is a free and open-source Python library designed for scientific and technical computing, extending the capabilities of by providing advanced algorithms and tools for numerical computations. It builds upon 's foundational array processing functionality to offer a comprehensive suite for handling complex mathematical operations in a Pythonic manner. The core scope of SciPy encompasses a wide range of algorithms essential for scientific workflows, including optimization techniques for minimizing or maximizing functions, for evaluating definite integrals, methods for estimating values between known data points, linear algebra routines for matrix operations and decompositions, statistical functions for probability distributions and hypothesis testing, tools for filtering and , and such as Bessel and gamma functions used in mathematical modeling. These capabilities enable efficient implementation of numerical methods without requiring users to develop low-level code from scratch. SciPy is licensed under the permissive BSD 3-clause license, which allows broad reuse and modification while ensuring attribution to original contributors. Its development follows a community-driven model, with contributions from a global network of volunteers coordinated through , fostering ongoing improvements and adaptability to emerging needs in . In high-level applications, SciPy supports a variety of use cases across for and systems design, physics for modeling physical phenomena and , and for exploratory computations and prototyping algorithms, all within an integrated environment. As part of the broader SciPy Stack ecosystem, it interoperates seamlessly with libraries like for array operations and others such as for visualization and for data manipulation.

Relationship with NumPy and the SciPy Stack

SciPy is fundamentally built upon , relying on its efficient array operations and mechanisms to handle multidimensional data structures central to scientific tasks. This dependency allows SciPy to leverage 's optimized C-based implementation for low-level numerical computations, ensuring high performance without duplicating core functionality. SciPy extends by providing a suite of domain-specific modules for advanced scientific applications, such as optimization, , and statistical analysis, while preserving 's role in fundamental data handling like array creation and manipulation. This architectural choice maintains a modular design where SciPy functions operate seamlessly on arrays, enhancing Python's capabilities for researchers without supplanting 's foundational tools. Within the broader Python scientific computing ecosystem, known as the SciPy Stack, SciPy integrates with complementary libraries including for data visualization, for symbolic mathematics, and or Jupyter for interactive computing environments. Originally formalized in 2012 as a distribution specification encompassing , SciPy, and these tools to promote , the SciPy Stack concept has evolved with modern package managers, though its component libraries continue to form a cohesive toolkit for scientific workflows. SciPy's with and other stack elements is further supported by standards like PEP 3118, which defines a revised buffer protocol for efficient memory sharing across Python extensions.

History

Origins and Early Projects

The foundations of SciPy emerged in the mid-1990s amid efforts to enable scientific computing in , building on early array libraries that addressed the language's limitations for numerical tasks. In 1995, Jim Hugunin released Numeric, an extension module that introduced array objects and basic numerical routines, laying the groundwork for efficient array-based computations in . This was soon complemented by contributions from developers like Konrad Hinsen, who created the ScientificPython package as a collection of modules referencing Numeric for broader scientific applications. Around the same time, Pearu Peterson began developing independent modules, including tools like F2PY for interfacing with code, which would later integrate into larger efforts. In 2001, the introduced Numarray as an alternative to Numeric, emphasizing support for large datasets and greater flexibility in array handling. SciPy was formally founded in 2001 through the collaborative efforts of , Eric Jones, and Pearu Peterson, who merged their independently developed codes—drawing from Numeric, Numarray, and other modules—into a unified scientific package. This merger addressed the fragmentation in Python's scientific ecosystem by consolidating algorithms for optimization, integration, linear algebra, and more, creating a cohesive that extended beyond mere array manipulation. The project's initial release marked a pivotal step, with , Jones, and Peterson establishing Enthought to support its development while keeping it open-source. A key distinction arose between "Scientific Python" as the informal, broader ecosystem encompassing tools like SciPy for collaborative scientific , and "ScientificPython" as Peterson's and others' earlier, more modular package focused on specific utilities, which was partially integrated into SciPy but later diverged to emphasize distinct functionalities like physical simulations. The core goal of SciPy from its was to deliver MATLAB-like capabilities—such as advanced numerical routines and tools—in an open-source environment, democratizing access to for researchers without dependencies. This vision positioned SciPy as a cornerstone for reproducible scientific workflows, with its array foundation evolving toward unification in by 2006.

Key Milestones and Releases

The first public release of SciPy occurred in 2001 with version 0.1, marking the initial consolidation of scientific computing tools built on Python's Numeric array library. This laid the groundwork for a unified of numerical algorithms. By , SciPy transitioned to integrate fully with , replacing the older Numeric and Numarray packages to standardize array handling and enhance compatibility across scientific workflows. A pivotal milestone came with the release of SciPy 1.0 on October 25, 2017, after 16 years of development, establishing long-term stability and policies to ensure reliability for users and downstream projects. This version introduced formal , including a Steering Council, to guide future directions. In 2013, SciPy became an affiliated project of NumFOCUS, a that provides and promotes sustainable open-source scientific computing, bolstering the project's longevity and community support. Recent releases have focused on performance, compatibility, and parallelism. SciPy 1.14.0, released on June 24, 2024, introduced experimental support for the Array API standard, enabling compatibility with parallel array libraries like , CuPy, and to facilitate . SciPy 1.15.0 followed on January 3, 2025, adding preliminary support for free-threaded 3.13, which allows safe parallel execution using Python's threading without the . The latest update, SciPy 1.16.3 on October 28, 2025, primarily addresses bug fixes and resolves issues such as memory leaks. By 2025, the project has grown to a community of over 1,000 unique contributors.

Data Structures

Integration with NumPy Arrays

SciPy relies on the ndarray as its foundational , enabling efficient handling of multi-dimensional, homogeneous across all numerical operations. This type facilitates advanced features like , which automatically expands of different shapes during element-wise computations, and , which applies operations to entire without explicit . These capabilities ensure that SciPy functions process in a compact, memory-efficient manner suitable for large-scale scientific computations. All SciPy subpackages utilize arrays for both input and output, promoting seamless interoperability and allowing users to pass ndarray objects directly between and SciPy routines without conversion overhead. For example, mathematical functions in scipy.special accept ndarray inputs and return array outputs, adhering to 's broadcasting rules to handle scalar-to-array expansions transparently. This uniform interface extends to other modules, such as optimization and integration, where array-based inputs enable of multiple data points in a single call. The adoption of in SciPy followed a key evolutionary step in 2005, when the project transitioned from the older Numeric library to NumPy's unified array interface, resolving fragmentation caused by competing implementations like numarray. This adaptation standardized SciPy's array handling, eliminating compatibility issues and aligning it with the emerging scientific ecosystem. Compatibility layers were provided to facilitate the upgrade, requiring minimal changes to existing C extensions. This tight integration yields performance advantages through in-memory operations on shared array objects, leveraging NumPy's views to avoid data copying during manipulations. Views reference the underlying data without duplication, allowing SciPy algorithms to execute vectorized computations rapidly—often orders of magnitude faster than equivalent pure loops—while minimizing memory footprint for high-dimensional datasets.

Specialized Structures like Sparse Matrices

SciPy extends NumPy's array capabilities with specialized data structures designed for efficient handling of large-scale, sparse, or multidimensional datasets that are common in scientific . The scipy.sparse module provides compressed storage formats for arrays and matrices containing predominantly zero elements, enabling substantial memory savings and faster computations compared to dense representations. Key formats include CSR (Compressed Sparse Row), which stores non-zero values row-wise with indices and pointers for efficient row-oriented operations; CSC (Compressed Sparse Column), optimized for column-wise access; and COO (Coordinate), a simple triplet format of row indices, column indices, and values suitable for construction and conversion. These formats support seamless interconversion in linear time, allowing users to select the most appropriate representation for specific tasks. Since SciPy 1.9 (), the module has been extended to support n-dimensional sparse arrays via classes like coo_array, csr_array, and csc_array, facilitating efficient handling of higher-dimensional sparse data. Building on these storage schemes, the sparse module facilitates a range of operations tailored for sparse linear algebra, such as matrix-vector multiplications and solving sparse linear systems via iterative methods in scipy.sparse.linalg. Eigenvalue computations for sparse matrices are available through specialized solvers that avoid full dense , preserving efficiency. Additionally, graph algorithms in scipy.sparse.csgraph, including shortest paths and connected components, leverage sparse adjacency matrices for . Beyond matrices, SciPy offers structures for multidimensional data in the scipy.ndimage module, which handles N-dimensional arrays representing images or volumetric data with specialized processing tools like filters, interpolations, and morphological operations that account for spatial relationships. For spatial queries, the scipy.spatial module includes tree-based structures such as and , which enable rapid nearest-neighbor searches in large point sets by organizing data in k-dimensional or ball-based hierarchies, respectively; these are particularly efficient for high-dimensional datasets where exhaustive searches would be prohibitive. These specialized structures are essential for memory-efficient processing of sparse or structured data in domains like numerical simulations and machine learning, where arrays and matrices with mostly zeros—such as those arising in finite element methods or graph neural networks—demand reduced storage without sacrificing computational performance.

Subpackages and Algorithms

Special Functions and Mathematical Constants

The scipy.special subpackage in SciPy provides a comprehensive collection of routines for computing special mathematical functions, including Bessel functions, gamma functions, and hypergeometric functions, all of which support vectorized operations on NumPy arrays for efficient numerical evaluation. These functions are essential for solving problems in applied mathematics and physics, with implementations drawing from established numerical methods to ensure high precision across a wide range of input values. For instance, the gamma function is computed via scipy.special.gamma(z), which evaluates the integral \Gamma(z) = \int_0^\infty t^{z-1} e^{-t} \, dt for \operatorname{Re}(z) > 0, and extends analytically to the complex plane; an example is scipy.special.gamma(3), which returns exactly 2.0, reflecting the factorial relation \Gamma(n) = (n-1)! for positive integers n. Bessel functions, such as the first-kind jv(nu, z) and second-kind yn(nu, z), along with their modified variants iv and kn, model cylindrical wave propagation and are widely used in physics applications like solving the wave equation in cylindrical coordinates. Hypergeometric functions, including the confluent form hyp1f1(a, b, z) and Gauss hypergeometric hyp2f1(a, b, c, z), facilitate solutions to differential equations in and other areas of . To achieve high accuracy, especially for large or complex arguments, the subpackage employs algorithms such as asymptotic expansions for rapid convergence in the regions and continued fractions for evaluation near singularities or points, as seen in the implementation of modified . In physics, these support computations in areas like wave propagation—via —and , where the appears in partition functions and distribution normalizations. The scipy.constants subpackage complements these tools by supplying a database of physical constants based on the 2022 CODATA recommendations, accessible through attributes like c for the or the dictionary physical_constants for detailed entries. For example, the is defined exactly as c = 299792458 m/s with no , while other constants include units in (e.g., meters per second, kilograms) and associated precision levels, such as relative uncertainties from CODATA measurements, enabling precise simulations in physical models.

Linear Algebra and Eigenvalue Problems

The scipy.linalg subpackage provides a comprehensive suite of tools for dense linear algebra operations, leveraging optimized BLAS and libraries for efficient computation of matrix decompositions, , and related tasks. It supports fundamental operations on arrays, enabling users to perform high-performance numerical computations in without needing to interface directly with lower-level code. Key decompositions include the LU factorization, which decomposes a matrix A into a lower triangular matrix L, an upper triangular matrix U, and a P such that P A = L U, useful for solving systems or computing determinants; this is implemented via functions like lu and lu_factor with partial pivoting for . The QR decomposition factors A = Q R, where Q is orthogonal and R is upper triangular, supporting modes such as 'economic' for reduced-size outputs; it aids in least-squares problems and orthogonalization. Singular value decomposition (SVD) computes A = U \Sigma V^H, with functions like svd providing full or truncated forms, essential for and pseudoinverses. For solving linear systems A x = b, the solve function directly computes the solution x for square, nonsingular matrices A, using internally for efficiency and reliability. Overdetermined systems are handled by lstsq, which minimizes the least-squares error using QR or approaches. Eigenvalue problems are addressed through functions like eig, which solves the general problem A v = \lambda v for complex using the via routines, suitable for nonsymmetric matrices. For symmetric or Hermitian matrices, eigh exploits structure for real eigenvalues, employing divide-and-conquer or QR-based methods to ensure numerical accuracy and speed. The scipy.sparse.linalg subpackage extends these capabilities to sparse matrices, focusing on memory-efficient algorithms for large-scale problems. Iterative solvers such as GMRES (Generalized Minimal Residual) approximate solutions to A x = b for sparse A, minimizing the residual in a with optional restarts to control memory usage; it is particularly effective for nonsymmetric systems where direct methods are infeasible. Eigenvalue solvers like eigsh compute a subset of eigenvalues and vectors for symmetric sparse matrices using the ARPACK library's implicitly restarted Arnoldi method. Additional utilities include norms via norm, which computes p-norms (e.g., Frobenius or ) for vectors and matrices; determinant calculation with det using ; and inverse computation with inv via factorization to avoid direct methods' instability. functions such as expm approximate the matrix exponential e^A using a variable-order scaled and squared for accuracy across different matrix norms. These tools collectively enable robust handling of linear algebra tasks in scientific computing, from small dense problems to large sparse systems.

Integration and Ordinary Differential Equations

The scipy.integrate subpackage provides tools for numerical integration of functions and solving ordinary differential equations (ODEs), enabling efficient computation of definite integrals and simulation of dynamical systems in scientific applications. It supports both scalar and vectorized operations, leveraging adaptive algorithms to balance accuracy and computational cost. These capabilities are essential for tasks ranging from physical modeling to , where exact analytical solutions are often unavailable. For numerical integration, the subpackage includes functions for computing definite integrals over one-dimensional and multi-dimensional domains. The quad function evaluates univariate definite integrals of the form \int_a^b f(x) \, dx, employing techniques from the QUADPACK library to handle finite, infinite, or improper intervals with high . It uses a combination of Gauss-Kronrod quadrature rules and error estimation to subdivide intervals where the integrand varies rapidly, ensuring the reported absolute or relative error remains below user-specified tolerances. For example, integrating oscillatory or singular functions benefits from this adaptive refinement, which dynamically adjusts step sizes based on local error estimates. Multi-dimensional integration is facilitated by dblquad, which computes double integrals \iint_D f(x, y) \, dx \, dy over rectangular or variable limits defined by functions g(x) and h(x). This function iteratively applies one-dimensional quadrature (via quad) along each dimension, incorporating adaptive stepping to manage computational expense in regions of high curvature. Error estimation in both quad and dblquad relies on comparing results from different quadrature orders, providing users with confidence intervals for the computed values. The subpackage addresses initial value problems (IVPs) for systems of ODEs of the form \frac{dy}{dt} = f(t, y), with initial conditions y(t_0) = y_0, through the solve_ivp function. This solver supports multiple integration methods, including explicit and implicit schemes with automatic step-size control. The default RK45 method is an explicit Runge-Kutta of 5(4), based on the embedded Dormand-Prince pair, which estimates local truncation errors to adaptively adjust step sizes for efficiency and accuracy. For stiff systems, the LSODA method automatically switches between non-stiff Adams integration and stiff backward differentiation formulas (BDF), drawing from the ODEPACK library to detect and handle stiffness dynamically. Both methods incorporate error estimation via embedded lower-order solutions, allowing tolerances to control the global error while minimizing function evaluations. Boundary value problems (BVPs), where conditions are specified at two points (e.g., y(a) = \alpha and y(b) = \beta), are solved using solve_bvp, which employs a method with finite differences and adaptive refinement. This approach discretizes the domain into a of points, approximating solutions with polynomials, and iteratively refines the based on residual errors to achieve . It supports systems of ODEs and handles nonlinear boundary conditions, making it suitable for problems in and .

Optimization and Root Finding

The scipy.optimize subpackage provides a comprehensive suite of algorithms for local and , root finding for nonlinear equations, and parameter estimation in , enabling efficient numerical solutions to a wide range of scientific computing problems. Central to local optimization is the minimize function, which offers a unified for minimizing scalar objective functions of one or more variables, supporting both derivative-free and -based methods. For unconstrained problems, the BFGS method approximates the inverse using rank-two updates based on evaluations, achieving superlinear without requiring second derivatives; this quasi-Newton approach was independently developed by Broyden, , Goldfarb, and Shanno in 1970. The Nelder-Mead , suitable for noisy or non-differentiable functions, performs derivative-free minimization by iteratively reflecting, expanding, or contracting a of trial points in the parameter space, as originally described by Nelder and in 1965. For , the SLSQP method employs sequential least-squares programming to handle nonlinear constraints, equality constraints, and bounds by solving quadratic subproblems iteratively; this implementation stems from Schittkowski's 1981 subroutine for . Root finding in scipy.optimize targets solutions to equations of the form F(x) = 0, where F may be scalar or multivariate. The fsolve function solves systems of nonlinear equations using a hybrid algorithm that combines Powell's dogleg trust-region strategy with a modified , ensuring robust even when information is unavailable or approximate; this hybrid approach was introduced by Powell in 1970 for nonlinear algebraic equations. For scalar functions, brentq locates roots within a [a, b] where f(a) and f(b) have opposite signs, employing —a of , , and inverse quadratic —for guaranteed and high efficiency, as proposed by Brent in 1971. These methods are particularly valuable in scientific applications requiring precise zero crossings, such as solving transcendental equations in physics or engineering. Global optimization algorithms in scipy.optimize address multimodal landscapes where local minima may trap standard methods. The differential_evolution function implements a population-based that evolves a set of candidate solutions through mutation, crossover, and selection, effectively exploring continuous spaces bounded by user-specified limits; this stochastic heuristic, known for its simplicity and robustness, was developed by Storn and Price in 1997. Complementing it, basinhopping performs a search by repeatedly perturbing the current solution and minimizing locally to "hop" between basins of attraction, mimicking physical annealing to escape local minima; the algorithm was introduced by and Doye in 1997 for finding low-energy configurations in molecular systems. Both are derivative-free and suitable for objective functions evaluated via expensive simulations. Curve fitting capabilities center on the curve_fit function, which estimates parameters of a nonlinear model y = f(x, p) by minimizing the least-squares residual between observed data and predictions, accounting for uncertainties in measurements. It employs the Levenberg-Marquardt algorithm, which blends for broad exploration with Gauss-Newton steps for rapid convergence near the minimum, using a damping parameter to balance the two; this hybrid method was refined by Marquardt in , building on Levenberg's earlier work. The function returns optimal parameters along with estimates, facilitating in fields like and .

Statistics and Probability Distributions

The scipy.stats subpackage provides a comprehensive of tools for statistical analysis and probability modeling in SciPy, enabling users to work with a wide of univariate and multivariate distributions, perform inferential tests, generate random samples, and apply non-parametric methods. It supports over 100 probability distributions, each implemented as a frozen or flexible object that allows parameterization and computation of key statistical functions. These tools are built on arrays for efficient vectorized operations, making them suitable for large-scale data analysis in scientific computing. Central to the subpackage are methods for evaluating probability functions (PDF), cumulative functions (CDF), and percent point functions (PPF) for various . For the , implemented via scipy.stats.[norm](/page/Norm), the PDF is given by f(x; \mu, \sigma) = \frac{1}{\sigma \sqrt{2\pi}} \exp\left( -\frac{(x - \mu)^2}{2\sigma^2} \right), where \mu is the mean () and \sigma is the standard deviation (); this can be computed as norm.pdf(x, [loc](/page/LOC)=μ, [scale](/page/Scale)=σ). The CDF, norm.cdf(x, [loc](/page/LOC)=μ, [scale](/page/Scale)=σ), returns the probability that a is less than or equal to x, while the PPF, norm.ppf(q, [loc](/page/LOC)=μ, [scale](/page/Scale)=σ), inverts the CDF to find the for a given probability q. Similar methods apply to other , such as the (scipy.stats.expon) or (scipy.stats.uniform), facilitating tasks like and analysis. Hypothesis testing functions in scipy.stats support classical inferential procedures, including parametric and contingency table tests. The independent two-sample t-test, ttest_ind(a, b), computes the t-statistic and p-value to assess whether two samples come from populations with equal means, assuming normality; it returns a Ttest_indResult object for further inspection. For categorical data, chi2_contingency(observed), performs a chi-squared test of independence on a contingency table, yielding the chi-squared statistic, p-value, degrees of freedom, and expected frequencies to evaluate associations between variables. These functions often integrate with optimization routines from other SciPy subpackages for maximum likelihood estimation of distribution parameters prior to testing. Random number generation in scipy.stats enables simulation of stochastic processes, with each distribution providing an .rvs() method for sampling. For multivariate cases, multivariate_normal.rvs(mean, cov, size=n) draws samples from a specified by a and , useful for modeling correlated random variables in fields like and physics. This capability underpins simulations, where repeated sampling approximates integrals, expectations, or complex probabilities; for instance, integrating a over a can be achieved by averaging .rvs() outputs. Non-parametric methods in the subpackage avoid distributional assumptions, focusing on empirical data properties. The Kolmogorov-Smirnov test, kstest(rv_variable, cdf, args=()), evaluates goodness-of-fit by comparing a sample's empirical CDF to a specified theoretical CDF, returning a and ; an example is kstest(data, 'norm', args=(μ, σ)) to check . This test is particularly valuable for validating model assumptions in without relying on parametric forms.

Signal Processing and Image Analysis

The scipy.signal subpackage provides a suite of tools for digital signal processing, enabling operations on one-dimensional and multidimensional signals represented as NumPy arrays. Central to this is support for Fourier transforms, including the multidimensional discrete Fourier transform via fftpack.fftn, which computes the FFT along specified axes for efficient frequency-domain analysis of signals and images. Filter design and application are key features, with functions like butter for generating Infinite Impulse Response (IIR) Butterworth filters, which are commonly used for low-pass, high-pass, or band-pass filtering due to their maximally flat frequency response in the passband. For phase-sensitive applications, filtfilt implements zero-phase forward-backward filtering, applying the filter twice—once forward and once backward—to eliminate phase distortion while doubling the effective filter order. Convolution operations, such as convolve and fftconvolve, facilitate linear filtering and system response simulations by computing the convolution of signals, with the FFT-based variant optimizing performance for large inputs. Spectral analysis tools in scipy.signal support time-frequency decompositions, including the welch method for estimating power spectral density (PSD) via Welch's averaged periodogram, which reduces variance by segmenting the signal and applying windowing to mitigate spectral leakage. The spectrogram function computes a time-localized PSD, useful for non-stationary signals, by applying short-time Fourier transforms with configurable windows like Hamming or Hann. Wavelet transforms are available through the continuous wavelet transform (cwt), which convolves the signal with scalable wavelet functions like the Morlet or Ricker wavelets to reveal localized frequency content, aiding in feature detection such as peaks via find_peaks_cwt. These capabilities extend to multidimensional data, supporting applications in audio processing and vibration analysis. The scipy.ndimage subpackage focuses on multidimensional image processing, offering filters and transformations for array-based images. Gaussian filters, implemented in gaussian_filter and gaussian_filter1d, apply isotropic or anisotropic to reduce while preserving edges, using the Gaussian defined by \sigma for the deviation, which controls the degree of blurring. Morphological operations include and (binary_erosion, grey_erosion) and (binary_dilation, grey_dilation), which shrink or expand image regions based on structuring elements, enabling removal, gap filling, and extraction in images or intensity maps. Advanced morphology like binary_opening combines and to remove small objects without altering larger structures. Interpolation routines in scipy.ndimage support resampling and geometric transformations, with zoom for uniform scaling via spline or nearest-neighbor methods, and rotate for angular resampling using spline interpolation to minimize aliasing. These tools, such as map_coordinates for arbitrary coordinate mappings, facilitate image resizing, warping, and alignment while maintaining data integrity. For image quality assessment, while scipy.ndimage emphasizes processing primitives, related metrics like structural similarity can be computed using luminance, contrast, and structure comparisons derived from filtered versions of the images, though full implementations often build on these foundations. Together, these features make SciPy a foundational toolkit for preprocessing signals and images in scientific computing, from denoising time series to enhancing medical scans.

Interpolation, Spatial Algorithms, and Clustering

The scipy.interpolate subpackage provides a suite of tools for constructing interpolating functions from points, supporting one-dimensional, multivariate, and spline-based methods. Central to this is interp1d, a class that enables piecewise in one dimension, allowing users to specify the kind of such as linear, cubic, or nearest-neighbor, and extrapolate beyond the range if needed. For scattered in higher s, griddata offers on unstructured grids using methods like nearest, linear, or cubic, facilitating the creation of regular grids from irregular observations. Spline is handled through classes like UnivariateSpline, which fits a to with controllable smoothness parameters, useful for applications requiring differentiable approximations. The scipy.spatial subpackage implements algorithms for spatial data analysis, including geometric structures and distance computations essential for computational geometry tasks. It features Delaunay triangulation via the Delaunay class, which constructs a simplicial mesh from input points by maximizing the minimum angle of triangles, providing a foundation for finite element methods and terrain modeling. Convex hull computation is available through ConvexHull, which determines the smallest convex set containing all points using algorithms like Qhull, returning facets, vertices, and volumes for further analysis. Distance metrics are supported by functions such as cdist, which efficiently computes pairwise distances between two sets of points using Euclidean, Manhattan, or other norms, enabling applications in nearest-neighbor searches and similarity assessments. Clustering capabilities reside in the scipy.cluster subpackage, which offers algorithms for grouping data based on similarity measures. The hierarchy module supports through the linkage function, which builds a of clusters from a condensed using methods like single, complete, average, or Ward's linkage, allowing via dendrograms for exploratory analysis. For partitioning-based clustering, the vq module provides k-means via kmeans and vq functions, which iteratively assign points to centroids and update them to minimize within-cluster variance, suitable for on moderate-sized datasets. These tools integrate with distance metrics from scipy.spatial for flexible input handling. SciPy's datasets module supplies built-in sample datasets for algorithm testing and demonstration, such as the electrocardiogram signal and the face image.

References

  1. [1]
    SciPy v1.16.2 Manual
    Sep 11, 2025 · SciPy (pronounced “Sigh Pie”) is an open-source software for mathematics, science, and engineering. User guide. API reference.SciPy User Guide · SciPy API · SciPy 1.10.1 Documentation · Installation
  2. [2]
    SciPy 1.0: fundamental algorithms for scientific computing in Python
    Feb 3, 2020 · Since its initial release in 2001, SciPy has become a de facto standard for leveraging scientific algorithms in Python, with over 600 unique ...<|control11|><|separator|>
  3. [3]
    SciPy
    SciPy provides algorithms for optimization, integration, interpolation, eigenvalue problems, algebraic equations, differential equations, statistics and many ...Documentation · Frequently Asked Questions · SciPy User Guide · About Us
  4. [4]
    History_of_SciPy - SciPy wiki dump
    This page sketches the history of SciPy and should clarify the differences/relations between SciPy, Numeric, numarray, NumPy and other related packages/ ...
  5. [5]
    SciPy 1.0 — 16 Years in the Making - NumFOCUS
    Nov 3, 2017 · SciPy Development Timeline: 2001: the first SciPy release; 2005: transition to NumPy; 2007: creation of scikits; 2008: scipy.spatial module and ...
  6. [6]
    News - SciPy
    January 3, 2025 – SciPy 1.15.0 has been released! This is the first stable release to provide Python 3.13 free-threading binaries on PyPI. SciPy 1.14.1 released ...
  7. [7]
  8. [8]
  9. [9]
    SciPy User Guide — SciPy v1.16.2 Manual
    SciPy is a collection of mathematical algorithms and convenience functions built on NumPy. It adds significant power to Python by providing the user with high- ...Statistics (scipy.stats) · Scipy.cluster · Scipy.ndimage · Optimization (scipy.optimize)
  10. [10]
    The SciPy Stack specification
    The SciPy Stack specification was developed in 2012. As of 2017, the SciPy Stack concept is obsolete given improvements in package management and distribution.
  11. [11]
    PEP 3118 – Revising the buffer protocol | peps.python.org
    Aug 28, 2006 · This PEP proposes re-designing the buffer interface ( PyBufferProcs function pointers) to improve the way Python allows memory sharing in Python 3.0.Missing: SciPy interoperability
  12. [12]
    Travis E. Oliphant, "NumPy and SciPy: History and Ideas for the ...
    The document details the history and future ideas for the Python libraries NumPy and SciPy, highlighting their development from the late 1990s to early ...
  13. [13]
    SciPy 1.0.0 Release Notes
    We are extremely pleased to announce the release of SciPy 1.0, 16 years after version 0.1 saw the light of day. It has been a long, productive journey to get ...Missing: milestones | Show results with:milestones
  14. [14]
    scipy 1.0.0 - PyPI
    Release history Release notifications | RSS feed · 1.16.2. Sep 11, 2025 · 1.16.1 ... gz . File metadata. Download URL: scipy-1.0.0.tar.gz; Upload date: Oct 25, ...
  15. [15]
    SciPy and MathJax join NumFOCUS Sponsored Projects
    Jun 11, 2019 · SciPy has been a NumFOCUS affiliated project since 2013. SciPy is used in virtually all fields of science and engineering. From major scientific ...<|separator|>
  16. [16]
    SciPy 1.14.0 Release Notes
    SciPy 1.14.0 is the culmination of 3 months of hard work. It contains many new features, numerous bug-fixes, improved test coverage and better documentation.Contents
  17. [17]
  18. [18]
    SciPy 1.16.0 Release Notes
    SciPy 1.16.0 includes new features, bug fixes, improved array API support, JAX/Dask support, and a new COBYLA implementation. It also has improved test ...
  19. [19]
    The N-dimensional array (ndarray) — NumPy v2.3 Manual
    An ndarray is a (usually fixed-size) multidimensional container of items of the same type and size.Numpy.ndarray · Numpy.ndarray.shape · Indexing routinesMissing: central | Show results with:central
  20. [20]
    Special functions (scipy.special) — SciPy v1.16.2 Manual
    Almost all of the functions below accept NumPy arrays as input arguments as well as single numbers. This means they follow broadcasting and automatic array- ...Jv · 1.16.0 · 1.12.0 · 1.14.0
  21. [21]
    SciPy API — SciPy v1.16.2 Manual
    ### Summary of SciPy Subpackages Using NumPy ndarrays
  22. [22]
    Frequently Asked Questions - SciPy.org
    NumPy has been the standard array package for a number of years now. If you use Numeric or numarray, you should upgrade; NumPy is explicitly designed to have ...
  23. [23]
    Array creation — NumPy v2.3 Manual
    Many Python libraries, including SciPy, Pandas, and OpenCV, use NumPy ndarrays as the common format for data exchange, These libraries can create, operate on, ...Missing: central | Show results with:central
  24. [24]
    Sparse arrays (scipy.sparse) — SciPy v1.16.2 Manual
    This package is switching to an array interface, compatible with NumPy arrays, from the older matrix interface. We recommend that you use the array objects ( ...Sparse matrices (scipy.sparse) · Sparse linear algebra · Csr_array · Coo_array
  25. [25]
    Sparse linear algebra (scipy.sparse.linalg) — SciPy v1.16.2 Manual
    The scipy.sparse.linalg module provides matrix operations, solving linear problems, matrix factorizations, and solving for eigenvalues and singular values.1.14.0 · 1.13.1 · Spsolve · Eigsh
  26. [26]
  27. [27]
  28. [28]
  29. [29]
    [PDF] Parallel Algorithms for Adding a Collection of Sparse Matrices - arXiv
    Dec 19, 2021 · Sparse matrices power many modern scientific codes, in- cluding those that arise in simulations, data analytics, and machine learning. An ...
  30. [30]
  31. [31]
  32. [32]
  33. [33]
    scipy.special.iv — SciPy v1.16.2 Manual
    It uses a power series for small z, the asymptotic expansion for large abs(z), the Miller algorithm normalized by the Wronskian and a Neumann series for ...
  34. [34]
    Constants (scipy.constants) — SciPy v1.16.2 Manual
    ### Summary of SciPy Constants Subpackage (Official SciPy Documentation)
  35. [35]
  36. [36]
    Linear algebra (scipy.linalg) — SciPy v1.16.2 Manual
    scipy.linalg provides linear algebra functions, including matrix inversion, solving equations, solving eigenvalue problems, and matrix decompositions.Scipy.ndimage · Eig · 1.15.0 · 1.14.0Missing: subpackage | Show results with:subpackage
  37. [37]
    qr — SciPy v1.16.2 Manual
    Compute QR decomposition of a matrix. Calculate the decomposition A = Q R where Q is unitary/orthogonal and R upper triangular.Next scipy.linalg.qr · Qr · 1.12.0 · 1.7.1
  38. [38]
  39. [39]
    Eigenvalue Problems - The Netlib
    Version 3.0 of LAPACK introduced another new algorithm, xSTEGR, for finding all the eigenvalues and eigenvectors of a symmetric tridiagonal matrix. It is ...
  40. [40]
  41. [41]
  42. [42]
  43. [43]
    expm — SciPy v1.16.2 Manual
    Implements the algorithm given in [1], which is essentially a Pade approximation with a variable order that is decided based on the array data.Scipy.linalg.expm · Linalg.expm · Expm · 1.14.0
  44. [44]
    Integration and ODEs (scipy.integrate) — SciPy v1.16.2 Manual
    Solving initial value problems for ODE systems. The solvers are implemented as individual classes, which can be used directly (low-level usage) or through a ...Quad · Trapezoid · Solve_ivp · Solve_bvp
  45. [45]
    quad — SciPy v1.16.2 Manual
    Compute a definite integral. Integrate func from a to b (possibly infinite interval) using a technique from the Fortran library QUADPACK.1.7.0 · Quad · 1.11.4 · 1.13.0
  46. [46]
  47. [47]
    solve_ivp — SciPy v1.16.2 Manual
    This function numerically integrates a system of ordinary differential equations given an initial value.1.7.0 · 1.13.0 · Solve_ivp · 1.8.0Missing: exact | Show results with:exact
  48. [48]
    solve_bvp — SciPy v1.16.2 Manual
    This function numerically solves a first order system of ODEs subject to two-point boundary conditions.Missing: paper | Show results with:paper
  49. [49]
  50. [50]
  51. [51]
    A New Approach to Variable Metric Algorithms - Semantic Scholar
    A New Approach to Variable Metric Algorithms · R. Fletcher · Published in Computer/law journal 1970 · Computer Science, Mathematics.
  52. [52]
    Simplex Method for Function Minimization | The Computer Journal
    The simplex method minimizes a function by comparing values at (n+1) vertices, replacing the highest value, and adapting to the local landscape.
  53. [53]
    [PDF] Brent (1971) - Mathematical Sciences Institute, ANU
    An algorithm is presented for finding a zero of a function which changes sign in a given interval. The algorithm combines linear interpolation and inverse ...
  54. [54]
    Differential Evolution – A Simple and Efficient Heuristic for global ...
    Price, K. and Storn, R. (1996), Minimizing the Real Functions of the ICEC'96 contest by Differential Evolution, IEEE International Conference on Evolutionary ...
  55. [55]
  56. [56]
    Statistical functions (scipy.stats) — SciPy v1.16.2 Manual
    This module contains a large number of probability distributions, summary and frequency statistics, correlation functions and statistical tests.Scipy.stats.mstats · Stats.norm · Stats.expon · Stats.uniform
  57. [57]
    scipy.stats.norm — SciPy v1.16.2 Manual
    A normal continuous random variable. The location ( loc ) keyword specifies the mean. The scale ( scale ) keyword specifies the standard deviation.1.12.0 · 1.13.1 · 1.13.0 · NormMissing: subpackage hypothesis testing
  58. [58]
  59. [59]
  60. [60]
    fftn — SciPy v1.16.2 Manual
    Return multidimensional discrete Fourier transform. The returned array contains: y[j_1,..,j_d] = sum[k_1=0..n_1-1, ..., k_d=0..n_d-1]
  61. [61]
  62. [62]
  63. [63]
    Interpolation (scipy.interpolate) — SciPy v1.16.2 Manual
    Sub-package for functions and objects used in interpolation. See the user guide for recommendations on choosing a routine, and other usage details.Pchip_interpolate · Input and output (scipy.io) · SciPy v1.12.0 Manual · Interp1d
  64. [64]
    Clustering package (scipy.cluster) — SciPy v1.16.2 Manual
    The hierarchy module provides functions for hierarchical and agglomerative clustering. Its features include generating hierarchical clusters from distance ...Logo image · SciPy Constants · K-means clustering and vector... · 1.15.1Missing: subpackage | Show results with:subpackage
  65. [65]
    Datasets (scipy.datasets) — SciPy v1.16.2 Manual
    SciPy dataset files are stored within individual GitHub repositories under the SciPy GitHub organization, following a naming convention as 'dataset-<name>' , ...Scipy.differentiate · 1.15.2 · 1.14.1 · 1.13.1