SciPy
Scientific computing library for Python with optimization, integration, interpolation, signal and stats.
Official Documentation ↗SciPy 1.12+ / Python 3.9+. Check the official docs for the latest API surface.Installation
pip install scipyMethods
No methods match this filter.
Overview
SciPy extends NumPy with algorithms used in science and engineering: optimization, root finding, integration, interpolation, signal processing, sparse linear algebra and statistics.
Core Methods
optimize finds minima and roots, interpolate builds interpolating functions, integrate computes integrals and solves ODEs, and stats offers tests and distributions. Submodules are imported by name.
Usage Notes
Always inspect result objects for success and convergence rather than assuming a solution. Provide analytic gradients where available for faster and more accurate optimization.
Common Pitfalls
Ignoring the success flag treats diverged runs as valid results. Dense matrices where sparse ones are needed exhaust memory. Interpolation outside the sample range can extrapolate wildly with some methods.
FAQ
- How does scipy relate to numpy?
- SciPy builds on NumPy arrays and adds higher-level algorithms for optimization, integration, interpolation, signal processing and statistics, while NumPy stays focused on arrays.
- How do I choose an optimizer?
- Start with the default for smooth unconstrained problems, use methods like L-BFGS-B for bounds and Nelder-Mead for noisy or non-smooth objectives. Always check the success flag and result diagnostics.
- What is a sparse matrix for?
- Sparse matrices store only non-zero entries, saving memory for large graphs and linear systems. Convert dense data to sparse with scipy.sparse builders before solving.
Report a problem with this API docOpens a pre-filled issue on GitHub.