GizStack
View .mdOpen in ChatGPTOpen in Claude

gizai/tensor/stats

the statistics of a Tensor of any real element type (T extends Real: i64, u64, f64, i32, f32, ...), as numpy's mean, var, quantile and median over an ndarray. Each computes in f64 and gives f64, also for integers. gizlang/stats keeps the forms over a sequence that is not a tensor.

gizlang
import * as Stats from "gizai/tensor/stats";

Methods

Tensor.mean

gizlang
function Tensor.mean<T extends Real>(self: Tensor<T>): f64

The mean of every element; NaN for none.

Tensor.variance

gizlang
function Tensor.variance<T extends Real>(self: Tensor<T>, ddof: i64): f64

The variance of every element with DDOF degrees of freedom removed (0: population, 1: sample), in two passes.

Tensor.quantile

gizlang
function Tensor.quantile<T extends Real>(self: Tensor<T>, q: f64): f64

The Q-quantile (0 <= Q <= 1) of every element, interpolating between the closest ranks (numpy's default).

Tensor.median

gizlang
function Tensor.median<T extends Real>(self: Tensor<T>): f64

The middle element, or the mean of the two middle ones.

Tensor.meanAlong

gizlang
function Tensor.meanAlong<T extends Real>(self: Tensor<T>, axis: i64): Tensor<f64>

The mean along AXIS: a tensor of the other axes (numpy's mean(axis)).