Skip to content

Algorithms Reference

A flat catalog of every algorithm shipping in vizcrush, with the package and Rust crate that implements it. Use this page to find the right tool for a job, or as a jumping-off point into the per-package docs.

Downsampling

Reduce a paired (x, y) series to a smaller, visually-equivalent set.

AlgorithmFunctionPackageBest for
LTTB (Largest-Triangle-Three-Buckets)lttb()@vizcrush/downsampleSmooth time series, sensor metrics
MinMax-LTTBminMaxLttb()@vizcrush/downsampleSpiky data — financial, IoT bursts
M4 (Min-Max-Min-Max)m4()@vizcrush/downsamplePer-pixel rendering, max fidelity
LTOB (Largest-Triangle-One-Bucket)ltob()@vizcrush/downsampleFaster simpler variant of LTTB

All four return interleaved [x0, y0, x1, y1, …] Float64Arrays. Reference paper: Steinarsson, "Downsampling Time Series for Visual Representation" (2013).

Aggregation & statistics

AlgorithmFunction / ClassPackageNotes
Welford's online statsstats(), StreamingStats@vizcrush/aggregateOne-pass, numerically stable
Exact percentilespercentile()@vizcrush/aggregateSort + linear interpolation
t-digest (approximate percentiles)vizcrush-aggregate::tdigest(Rust crate)Approximate, sub-linear memory
Append-and-downsampleappendAndDownsample()@vizcrush/aggregateStreaming append + LTTB in one pass

Transforms

AlgorithmFunctionPackageCost
Radix sortsortBy()@vizcrush/transformO(n) for fixed-width floats
Min-max normalizenormalize()@vizcrush/transformO(n) two-pass
Range filterfilterRange()@vizcrush/transformO(n) single pass

Binning & density

AlgorithmFunctionPackageOutput
1D histogrambin1d()@vizcrush/binUint32Array counts + Float64Array edges
2D density gridbin2d()@vizcrush/binRow-major Uint32Array of size xBins*yBins
Hexagonal binninghexbin()@vizcrush/binSparse list of {cx, cy, count} cells
3D voxel binningbin3d()@vizcrush/bin3dFlat Uint32Array of size xBins*yBins*zBins

Spatial indexing

IndexBuild / Query functionsPackageDimensions
QuadtreebuildQuadtree, queryRange, queryNearest@vizcrush/spatial2D
OctreebuildOctree, queryRange3d, queryNearest3d@vizcrush/spatial3d3D
k-d tree(in vizcrush-spatial::kdtree, future export)(Rust crate)2D / N-D
Frustum cullingfrustumCull()@vizcrush/spatial3d3D, MVP-based

Both quadtree and octree use the same configuration: MAX_POINTS = 64 per leaf, MAX_DEPTH = 12.

AI & analysis

AlgorithmFunctionPackageImplementation
Anomaly detection (MAD + Z-score)detectAnomalies()@vizcrush/aiRobust to outliers, classifies spike/dip/shift
Changepoint detection (CUSUM)detectChangepoints()@vizcrush/aiSustained mean shifts
Auto-optimizationautoOptimize()@vizcrush/aiHeuristic algorithm + parameter selection
Data summarizationsummarize(), summarizeForLLM()@vizcrush/aiTrend, distribution, anomalies
Shape embeddingscomputeShapeVector()@vizcrush/ai16-dim feature vector
Shape similarityshapeSimilarity()@vizcrush/aiCosine similarity in [0, 1]
NL query parsingparseDataQuery()@vizcrush/aiRule-based, no LLM round-trip

Backend selection

FunctionPackagePurpose
init()@vizcrush/coreInitialize, auto-select best backend
detectCapabilities()@vizcrush/coreProbe runtime features
selectBackend(caps)@vizcrush/coreApply selection rules

The selection is: WASM → JS — WASM whenever WebAssembly is available, the pure-JS core otherwise. See Backends & Capabilities for details.

Performance reference

Run the suite in benchmarks/ for numbers on your hardware; results land in benchmarks/results/. Reference points from the latest Node run (pure-JS core, V8 — benchmarks/results/latest.json):

OperationInput sizeTime
lttb1M → 10001.8 ms
filterRange1M5.3 ms
stats1M3.9 ms

In Chromium, the WASM backend runs lttb 1M → 1000 in ~1.5 ms — WASM is roughly 4× faster than the JS core in Chromium/V8, but the JS core is comparable or faster in Firefox and WebKit, and the first WASM call pays a one-time module-load cost. See ADR 0003 (docs/adr/0003-wasm-vs-js-is-engine-dependent.md). No WebGPU compute path is wired for any of these algorithms.

See also

Released under the MIT License.