Skip to main content

Examples

These guides walk through real-world patterns using numpy-ts. Each example includes complete, runnable TypeScript code that you can copy directly into your project.

Linear Algebra

Solve systems of equations, compute eigenvalues and SVD, invert matrices, and perform matrix multiplication with matmul and dot.

Signal Processing with FFT

Build composite signals, compute Fourier transforms, filter frequencies, and apply convolution kernels.

Statistics & Analysis

Compute descriptive statistics, build histograms, calculate correlation matrices, run Monte Carlo simulations, and weighted averages.

Image Processing Patterns

Represent images as arrays, slice regions of interest, adjust brightness and contrast, reorder channels, and apply convolution filters.

Data Loading & I/O

Load .npy and .npz files in Node.js and browsers, parse CSV data, and work with text-based formats.

Performance Tips

Minimize copies with views, pick the right entry point for tree-shaking, choose efficient dtypes, and prefer vectorized operations over loops.

Prerequisites

All examples assume you have numpy-ts installed:
npm install numpy-ts
Most examples use the full entry point for readability:
import * as np from 'numpy-ts';
For production browser bundles, consider using numpy-ts/core for tree-shaking. See the Tree-Shaking guide for details.