The finance developer workbenchSearch the reference Development · 0.1.4 · unpublished

Public API / @insiderfinance/totalfinance

@insiderfinance/totalfinance/math/statistics

import from '@insiderfinance/totalfinance/math/statistics'

Every public export in this entry point, including type-only declarations. Search by name or concept.

Jump to an export (28)

KurtosisOptions · MedianAbsoluteDeviationOptions · NanPolicy · PopulationOptions · StatisticsOptions · TrimmedMeanOptions · VarianceOptions · WinsorizeOptions · correlation · covariance · kurtosis · max · mean · median · medianAbsoluteDeviation · min · quantile · rollingCorrelation · rollingCovariance · rollingMean · rollingStandardDeviation · skewness · standardDeviation · sum · trimmedMean · variance · welfordVariance · winsorize

interface

KurtosisOptions

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export interface KurtosisOptions extends StatisticsOptions {
    /** Return excess kurtosis (subtract 3). Default `true`. */
    excess?: boolean;
}
Fields, parameters & returned members (2)
Name / typeMeaning & unitOptional / default
excess
boolean
Return excess kurtosis (subtract 3). Default `true`.
unitless by name
Optional
No @default declared; consult the signature and description.
nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

interface

MedianAbsoluteDeviationOptions

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

// ---- robust statistics ----
export interface MedianAbsoluteDeviationOptions extends StatisticsOptions {
    /** Scale by 1.4826 for consistency with the normal stddev (default `true`). */
    scale?: boolean;
}
Fields, parameters & returned members (2)
Name / typeMeaning & unitOptional / default
nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
scale
boolean
Scale by 1.4826 for consistency with the normal stddev (default `true`).
unitless by name
Optional
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

type

NanPolicy

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export type NanPolicy = 'propagate' | 'omit' | 'throw';
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

interface

PopulationOptions

The estimator choice alone — the whole contract of the rolling family and `covarianceMatrix`.

/** The estimator choice alone — the whole contract of the rolling family and `covarianceMatrix`. */
export interface PopulationOptions {
    /** Use the population estimator (÷n) instead of the sample estimator (÷(n-1)). */
    population?: boolean;
}
Fields, parameters & returned members (1)
Name / typeMeaning & unitOptional / default
population
boolean
Use the population estimator (÷n) instead of the sample estimator (÷(n-1)).
unitless by name
Optional
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

interface

StatisticsOptions

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export interface StatisticsOptions {
    nanPolicy?: NanPolicy;
}
Fields, parameters & returned members (1)
Name / typeMeaning & unitOptional / default
nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

interface

TrimmedMeanOptions

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export interface TrimmedMeanOptions extends StatisticsOptions {
    /**
     * Fraction dropped from EACH tail before averaging (default 0.1), in [0, 0.5]. At 0.5 nothing
     * but the middle remains and the result is the median; the same fallback applies whenever the
     * two trims would consume the whole sample.
     */
    fraction?: number;
}
Fields, parameters & returned members (2)
Name / typeMeaning & unitOptional / default
fraction
number
Fraction dropped from EACH tail before averaging (default 0.1), in [0, 0.5]. At 0.5 nothing but the middle remains and the result is the median; the same fallback applies whenever the two trims would consume the whole sample.
unitless by name
Optional
No @default declared; consult the signature and description.
nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

interface

VarianceOptions

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export interface VarianceOptions extends StatisticsOptions, PopulationOptions {
}
Fields, parameters & returned members (2)
Name / typeMeaning & unitOptional / default
nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
population
boolean
Use the population estimator (÷n) instead of the sample estimator (÷(n-1)).
unitless by name
Optional
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

interface

WinsorizeOptions

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export interface WinsorizeOptions extends StatisticsOptions {
    /** Lower tail fraction to clip (default 0.05). */
    lower?: number;
    /** Upper tail fraction to clip (default 0.05). */
    upper?: number;
}
Fields, parameters & returned members (3)
Name / typeMeaning & unitOptional / default
lower
number
Lower tail fraction to clip (default 0.05).
unitless by name
Optional
No @default declared; consult the signature and description.
nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
upper
number
Upper tail fraction to clip (default 0.05).
unitless by name
Optional
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

correlation

Pearson correlation coefficient. Throws on unequal lengths.

export declare function correlation(xs: ArrayLike<number>, ys: ArrayLike<number>, options?: StatisticsOptions): number;
Fields, parameters & returned members (4)
Name / typeMeaning & unitOptional / default
(options)
StatisticsOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
(ys)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

covariance

Covariance of two equal-length series (sample by default). Throws on unequal lengths.

export declare function covariance(xs: ArrayLike<number>, ys: ArrayLike<number>, options?: VarianceOptions): number;
Fields, parameters & returned members (5)
Name / typeMeaning & unitOptional / default
(options)
VarianceOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(options).population
boolean
Use the population estimator (÷n) instead of the sample estimator (÷(n-1)).
unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
(ys)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

kurtosis

Population kurtosis; excess (−3) by default.

export declare function kurtosis(xs: ArrayLike<number>, options?: KurtosisOptions): number;
Fields, parameters & returned members (4)
Name / typeMeaning & unitOptional / default
(options)
KurtosisOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).excess
boolean
Return excess kurtosis (subtract 3). Default `true`.
unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

max

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export declare function max(xs: ArrayLike<number>, options?: StatisticsOptions): number;
Fields, parameters & returned members (3)
Name / typeMeaning & unitOptional / default
(options)
StatisticsOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

mean

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export declare function mean(xs: ArrayLike<number>, options?: StatisticsOptions): number;
Fields, parameters & returned members (3)
Name / typeMeaning & unitOptional / default
(options)
StatisticsOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

median

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export declare function median(xs: ArrayLike<number>, options?: StatisticsOptions): number;
Fields, parameters & returned members (3)
Name / typeMeaning & unitOptional / default
(options)
StatisticsOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

medianAbsoluteDeviation

Median absolute deviation.

export declare function medianAbsoluteDeviation(xs: ArrayLike<number>, options?: MedianAbsoluteDeviationOptions): number;
Fields, parameters & returned members (4)
Name / typeMeaning & unitOptional / default
(options)
MedianAbsoluteDeviationOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(options).scale
boolean
Scale by 1.4826 for consistency with the normal stddev (default `true`).
unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

min

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export declare function min(xs: ArrayLike<number>, options?: StatisticsOptions): number;
Fields, parameters & returned members (3)
Name / typeMeaning & unitOptional / default
(options)
StatisticsOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

quantile

Quantile via the type-7 (linear interpolation of order statistics) method — the default used by NumPy and R. `p` is in [0, 1].

export declare function quantile(xs: ArrayLike<number>, probability: number, options?: StatisticsOptions): number;
Fields, parameters & returned members (4)
Name / typeMeaning & unitOptional / default
(options)
StatisticsOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(probability)
number

unitless by name
Required / declared member
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

rollingCorrelation

Rolling Pearson correlation over a window. Aligned with `NaN` warmup.

export declare function rollingCorrelation(xs: ArrayLike<number>, ys: ArrayLike<number>, window: number): number[];
Fields, parameters & returned members (3)
Name / typeMeaning & unitOptional / default
(window)
number

unitless by name
Required / declared member
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
(ys)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

rollingCovariance

Rolling covariance over a window. Aligned with `NaN` warmup. Takes {@link PopulationOptions} for the same reason as {@link rollingStandardDeviation}.

export declare function rollingCovariance(xs: ArrayLike<number>, ys: ArrayLike<number>, window: number, options?: PopulationOptions): number[];
Fields, parameters & returned members (5)
Name / typeMeaning & unitOptional / default
(options)
PopulationOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).population
boolean
Use the population estimator (÷n) instead of the sample estimator (÷(n-1)).
unitless by name
Optional
No @default declared; consult the signature and description.
(window)
number

unitless by name
Required / declared member
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
(ys)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

rollingMean

Rolling mean. Output length equals input; the first `window-1` values are `NaN`. A window holding a non-finite value — or whose own sum overflows — is reported `NaN`, never `±Infinity` (see {@link finiteOrNaN}).

export declare function rollingMean(xs: ArrayLike<number>, window: number): number[];
Fields, parameters & returned members (2)
Name / typeMeaning & unitOptional / default
(window)
number

unitless by name
Required / declared member
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

rollingStandardDeviation

Rolling standard deviation (sample by default). Aligned with `NaN` warmup. Takes {@link PopulationOptions}, not `VarianceOptions`: the rolling family has no `nanPolicy` (see the module conventions), so the field is rejected as unknown rather than accepted and ignored.

export declare function rollingStandardDeviation(xs: ArrayLike<number>, window: number, options?: PopulationOptions): number[];
Fields, parameters & returned members (4)
Name / typeMeaning & unitOptional / default
(options)
PopulationOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).population
boolean
Use the population estimator (÷n) instead of the sample estimator (÷(n-1)).
unitless by name
Optional
No @default declared; consult the signature and description.
(window)
number

unitless by name
Required / declared member
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

skewness

Population skewness (third standardized moment).

export declare function skewness(xs: ArrayLike<number>, options?: StatisticsOptions): number;
Fields, parameters & returned members (3)
Name / typeMeaning & unitOptional / default
(options)
StatisticsOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

standardDeviation

Public declaration. Read the signature and parameter/member contracts below; no additional behavior is inferred.

export declare function standardDeviation(xs: ArrayLike<number>, options?: VarianceOptions): number;
Fields, parameters & returned members (4)
Name / typeMeaning & unitOptional / default
(options)
VarianceOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(options).population
boolean
Use the population estimator (÷n) instead of the sample estimator (÷(n-1)).
unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

sum

Kahan-compensated sum — minimizes rounding error over long series.

export declare function sum(xs: ArrayLike<number>, options?: StatisticsOptions): number;
Fields, parameters & returned members (3)
Name / typeMeaning & unitOptional / default
(options)
StatisticsOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.

function

trimmedMean

Trimmed mean: drop `fraction` of the data from each tail, then average the rest.

export declare function trimmedMean(xs: ArrayLike<number>, options?: TrimmedMeanOptions): number;
Fields, parameters & returned members (4)
Name / typeMeaning & unitOptional / default
(options)
TrimmedMeanOptions | undefined

unitless by name
Optional
No @default declared; consult the signature and description.
(options).fraction
number
Fraction dropped from EACH tail before averaging (default 0.1), in [0, 0.5]. At 0.5 nothing but the middle remains and the result is the median; the same fallback applies whenever the two trims would consume the whole sample.
unitless by name
Optional
No @default declared; consult the signature and description.
(options).nanPolicy
NanPolicy

unitless by name
Optional
No @default declared; consult the signature and description.
(xs)
ArrayLike<number>

unitless by name
Required / declared member
No @default declared; consult the signature and description.
Stability, warnings & conventions
stable-by-law (pre-1.0; not a 1.0 stability guarantee)

Declared field units are shown above. “Unitless by name” means the name alone does not establish a unit, not that a financial quantity has none. Check source descriptions, conventions, and the returned diagnostics. Errors and warnings are part of the result contract.