std

Calculates standard deviation as the square root of variance(values, options).

import { Arith } from "@teakit/arith";

Arith.std(["1", "2", "3"]).toString(); // "0.81649658092772603273"
Arith.std(["1", "2", "3"], { sample: true }).toString(); // "1"

const Short = Arith.clone({ DECIMAL_PLACES: 4 });
Short.std(["1", "2", "3"]).toString(); // "0.8165"

API Reference

Signature

Arith.std(values: readonly ArithValue[], options?: ArithSampleOptions): ArithInstance;

Parameters

ParameterTypeRequiredNotes
valuesreadonly ArithValue[]YesNon-empty array of finite values.
options.samplebooleanNofalse or omitted uses population standard deviation. true uses sample standard deviation.

Returns

Returns Arith.variance(values, options).sqrt().

Throws

  • Throws if values is not a non-empty array.
  • Throws if any value is non-finite.
  • Throws if sample: true is used with fewer than two values.
  • Throws if options.sample is not boolean when provided.

Agent Contract

FieldValue
Kindstatic method
Canonical namestd
AliasesNone
Mutates receiverNo
ReturnsArithInstance
Accepts (string, base) overloadNo
Configuration dependenciesDECIMAL_PLACES, ROUNDING_MODE, STRICT
Related methodsvariance, sqrt

Agent Notes

  • Use std, not standardDeviation.
  • Population standard deviation is the default.