scipy

Science

Scientific computing

Try scipy in PyRun

What is scipy?

SciPy builds on NumPy to provide a large collection of algorithms for scientific and technical computing. It includes modules for optimization, linear algebra, integration, interpolation, signal processing, statistics, and more. SciPy is used by physicists, engineers, and data scientists who need precise numerical methods beyond basic array math.

PyRun includes SciPy as a bundled Pyodide package. You can use scipy.optimize, scipy.stats, scipy.interpolate, and other submodules directly in your browser — no local installation required. It's an ideal environment for testing numerical algorithms or exploring scientific methods interactively.

Code Example

Numerical root finding and descriptive statistics.

SciPy Root Finding & Stats
Try in Editor
from scipy import optimize, stats
import numpy as np

# Root finding
def f(x):
    return x**3 - 2*x - 5

result = optimize.root_scalar(f, bracket=[2, 3], method='brentq')
print("Root of f(x) = x³ - 2x - 5:")
print(f"  x = {result.root:.6f}  (converged: {result.converged})")

# Basic statistics
data = np.array([2.1, 2.5, 3.0, 3.2, 3.8, 4.0, 4.5, 5.1])
print("\nDescriptive stats:")
print(f"  mean   = {np.mean(data):.3f}")
print(f"  median = {np.median(data):.3f}")
print(f"  stdev  = {np.std(data):.3f}")
t_stat, p_val = stats.ttest_1samp(data, popmean=3.5)
print(f"\nOne-sample t-test (μ=3.5): t={t_stat:.4f}, p={p_val:.4f}")

Why run scipy in PyRun?

  • Zero setup — no pip install, no virtual environment, no Python download
  • Instant results — powered by WebAssembly, runs locally in your browser
  • Share your code — generate a link and anyone can run it instantly
  • Works offline — after first load, PyRun runs without internet
Open editor with scipy example

Related Packages