Skip to content

Function.variance

github-actions[bot] edited this page Nov 18, 2026 · 13 revisions

umt / variance

Function: variance()

variance(values, sample?): number

Defined in: Math/variance.ts:17

Calculates the variance of a set of values

Parameters

values

number[]

Array of numeric values

sample?

boolean = false

If true, divides by n - 1 (sample variance) instead of n (population variance)

Returns

number

The variance, 0 for an empty array, or NaN for a sample of a single value

Examples

variance([1, 2, 3]); // 0.6666666666666666
variance([1, 2, 3], true); // 1
variance([10, 12, 23, 23, 16, 23, 21, 16]); // 24

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally