The VikiD Truth

Knowledge base / Computing

computingFreedom | Build | Picolisp | Picolisp Machine | pil sources | Linux | BASH | C Programmming | Operating Systems | Javascipt | Emacs | vim | Pharo Smalltalk | Computer Security | Python |

SciPy

Here is the truth about SciPy: it is the standard library Python never shipped for science and engineering. Where NumPy gives you arrays, SciPy gives you the algorithms that use them – integration, optimisation, signal processing, statistics, sparse linear algebra and more.

What it is, in plain words

SciPy (pronounced “sigh pie”) is an open-source Python library built on NumPy. It collects battle-tested implementations of classical numerical methods, many of them wrappers around the same Fortran and C libraries (QUADPACK, FFTpACK, ARPACK, ODEPACK, LAPACK) that scientists have trusted for decades. The top-level packages you’ll actually import:

PackageJob
scipy.integratenumerical integration, ODE solvers
scipy.optimizeroot finding, curve fitting, minimisation
scipy.linalgdenser linear algebra than numpy.linalg
scipy.sparsesparse matrices and solvers
scipy.signalfiltering, convolution, spectral analysis
scipy.statsdistributions, tests, descriptive stats
scipy.interpolatesplines and interpolants
scipy.fftFourier transforms
scipy.ndimageN-dimensional image processing
scipy.spatialKD-trees, distance computations
scipy.specialBessel, gamma, erf and friends
scipy.ioMATLAB .mat, Matrix Market, wav, etc.

SciPy 1.x is mature; releases continue steadily in 2026. It shares NumPy’s array object, so the two feel like one system.

Why it matters

Before SciPy (and its sibling ecosystem – Matplotlib, pandas, scikit-learn), serious numerics meant MATLAB, Fortran or C. SciPy gave Python a free, coherent alternative that runs everywhere. If you do data analysis, physics, DSP, optimisation or stats in Python, you are standing on it – even when a higher-level library is what you import.

An everyday analogy: a well-stocked lab bench

NumPy is the set of clean glass beakers (the containers). SciPy is the instruments on the bench: the balance, the spectrometer, the centrifuge. Same beakers, specialised tools that know how to use them.

flowchart LR
  N[NumPy ndarray] --> S[SciPy algorithms]
  S --> M[Matplotlib plots]
  S --> P[pandas / scikit-learn]
  F[Fortran/C libraries] --> S

A hands-on example

pip install numpy scipy matplotlib
import numpy as np
from scipy import integrate, optimize, signal, stats

# 1. Integrate a function: ∫_0^π sin(x) dx = 2
area, err = integrate.quad(np.sin, 0, np.pi)
print(area, err)

# 2. Solve an ODE: y' = -2y, y(0) = 1
sol = integrate.solve_ivp(lambda t, y: -2 * y, [0, 3], [1], dense_output=True)
print(sol.sol(1.0))            # ≈ e^{-2} ≈ 0.135

# 3. Fit a curve
def model(x, a, b): return a * np.exp(-b * x)
x = np.linspace(0, 4, 50)
y = model(x, 2.5, 1.3) + 0.2 * np.random.default_rng(0).normal(size=50)
params, _ = optimize.curve_fit(model, x, y, p0=(1, 1))
print(params)                  # ≈ [2.5, 1.3]

# 4. Filter a noisy signal
t = np.linspace(0, 1, 500, endpoint=False)
sig = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.default_rng(1).standard_normal(500)
b, a = signal.butter(4, 0.1)   # low-pass
clean = signal.filtfilt(b, a, sig)

# 5. A quick statistic
print(stats.describe(clean))
print(stats.ttest_1samp(clean, 0.0))

When a routine has a NumPy and a SciPy version (linear algebra especially), the SciPy one is often more complete – more decompositions, more solvers, better control over specialised cases. For sparse systems (most of a matrix is zeros), always look at scipy.sparse.linalg before a dense approach.

How it relates to the rest of the stack

Common misconceptions

Installing and versions

pip install "scipy>=1.11"
# or in a scientific stack:
pip install numpy scipy matplotlib pandas ipython

On Void: sudo xbps-install -S python3-scipy. Distro packages are fine for exploration; for research and production, use a venv or conda and pin versions so results stay reproducible.

Connections

Check Installation in Jupyter Notebooks:

import numpy as np
print("I like ", np.pi)

from scipy import misc
import matplotlib.pyplot as plt

face = misc.face()
plt.imshow(face)
plt.show()

Libraries, Tools

Last edited · 6 revisions

Tags: #Computing