Skip to content

Algorithms Reference ​

A catalog of the algorithm families shipping in vizcrush, with the package and Rust crate that implements them. Use this page to find the right tool for a job; the generated project inventory is the canonical runtime-export list.

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 { x: Float64Array, y: Float64Array }. 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
DDSketch / KLLDDSketch, KllSketch@vizcrush/aggregateBounded-memory approximate quantiles
Reservoir samplingReservoirSampler@vizcrush/aggregateBounded representative stream sample
HyperLogLogHyperLogLog@vizcrush/aggregateApproximate distinct-value count
Count-Min SketchCountMinSketch@vizcrush/aggregateApproximate frequencies/heavy hitters

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
Log / power transformlogTransform(), powerTransform()@vizcrush/transformO(n)
Quantile normalizationquantileNormalize()@vizcrush/transformO(n log n)

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
Spatial hash gridbuildHashGrid, hashGridQueryRadius, hashGridQueryRange@vizcrush/spatial2D
Morton orderingmortonOrder2d()@vizcrush/spatial2D
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

Automatic kernel calls use the JS core below their size threshold and otherwise try the package's WASM module, falling back to JS if it is unavailable. Explicit JS and WASM requests are also supported. See Backends & Capabilities for completed-call diagnostics and 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. How that compares to the JS core is engine- and version-dependent: WASM was roughly 4× faster through Chromium 148, but Chromium 149's V8 made the JS core 3.36× faster, so the two are now within ~1.1× there; 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) and benchmarks/campaign/. No WebGPU compute path is wired for any of these algorithms.

See also ​

Released under the MIT License.