GitHub
deepbox/stats

Descriptive & Correlation

Descriptive statistics, bootstrap helpers, and correlation routines for exploratory and inferential analysis.
EDA
Correlation
type KurtosisOptions
export interface KurtosisOptions { … }
Options bag for .
type MeanOptions
export interface MeanOptions { … }
Options bag for .
type SkewnessOptions
export interface SkewnessOptions { … }
Options bag for .
type VarianceOptions
export interface VarianceOptions { … }
Options bag for and .
corrcoef
export declare function corrcoef(x: Tensor, y?: Tensor): Tensor;

Computes the Pearson correlation coefficient matrix.

cov
export declare function cov(x: Tensor, y?: Tensor, ddof?: number): Tensor;

cov is exported by deepbox/stats.

kendalltau
export declare function kendalltau(x: Tensor, y: Tensor): [number, number];

kendalltau is exported by deepbox/stats.

partialcorr
export declare function partialcorr(x: Tensor, y: Tensor, z: Tensor | Tensor[]): [number, number];

Computes partial correlation between two variables controlling for confounders.

pearsonr
export declare function pearsonr(x: Tensor, y: Tensor): [number, number];

Pearson correlation coefficient.

pointbiserialr
export declare function pointbiserialr(x: Tensor, y: Tensor): [number, number];

Computes the covariance matrix.

spearmanr
export declare function spearmanr(x: Tensor, y: Tensor): [number, number];

Computes Spearman's rank correlation coefficient.

bootstrap
export declare function bootstrap(data: number[], statFn: (sample: number[]) => number, options?: { nResamples?: number; seed?: number; confidenceLevel?: number; }): { estimate: number; ci: [number, number]; samples: number[]; };

Non-parametric bootstrap: resample a statistic.

cohenD
export declare function cohenD(a: number[], b: number[]): number;

Compute Cohen's d effect size between two samples.

geometricMean
export declare function geometricMean(t: Tensor, axis?: AxisLike): Tensor;

geometricMean is exported by deepbox/stats.

harmonicMean
export declare function harmonicMean(t: Tensor, axis?: AxisLike): Tensor;

Computes the harmonic mean along specified axis.

iqr
export declare function iqr(t: Tensor, axis?: AxisLike): Tensor;

Computes the interquartile range (IQR).

kurtosis
export declare function kurtosis(t: Tensor, axis?: AxisLike, fisher?: boolean, bias?: boolean): Tensor;

kurtosis is exported by deepbox/stats.

mean
export declare function mean(t: Tensor, axis?: AxisLike, keepdims?: boolean): Tensor;

mean is exported by deepbox/stats.

median
export declare function median(t: Tensor, axis?: AxisLike, keepdims?: boolean): Tensor;

Computes the median (50th percentile) along specified axes.

mode
export declare function mode(t: Tensor, axis?: AxisLike): Tensor;

Computes the mode (most frequent value) along specified axis.

moment
export declare function moment(t: Tensor, n: number, axis?: AxisLike): Tensor;

Computes the n-th central moment about the mean.

percentile
export declare function percentile(t: Tensor, q: number | number[], axis?: AxisLike): Tensor;

Computes percentiles along specified axes.

quantile
export declare function quantile(t: Tensor, q: number | number[], axis?: AxisLike): Tensor;

Computes quantiles along specified axes.

sem
export declare function sem(t: Tensor, axis?: AxisLike, ddof?: number): Tensor;

Computes the standard error of the mean (SEM).

skewness
export declare function skewness(t: Tensor, axis?: AxisLike, bias?: boolean): Tensor;

skewness is exported by deepbox/stats.

std
export declare function std(t: Tensor, axis?: AxisLike, keepdims?: boolean, ddof?: number): Tensor;

std is exported by deepbox/stats.

trimMean
export declare function trimMean(t: Tensor, proportiontocut: number, axis?: AxisLike): Tensor;

Computes the trimmed mean (mean after removing outliers from both tails).

variance
export declare function variance(t: Tensor, axis?: AxisLike, keepdims?: boolean, ddof?: number): Tensor;

variance is exported by deepbox/stats.

zscore
export declare function zscore(t: Tensor, ddof?: number): Tensor;

Compute the z-score of each element relative to the sample mean and std.

stats-descriptive.ts
import { corrcoef, mean, percentile, spearmanr, std, zscore } from "deepbox/stats";import { tensor } from "deepbox/ndarray";const x = tensor([1, 2, 3, 4, 5]);const y = tensor([2, 4, 3, 8, 7]);const paired = tensor([  [1, 2, 3, 4, 5],  [2, 4, 3, 8, 7],]);console.log(mean(x).toString(), std(x).toString(), percentile(x, 90).toString());console.log(zscore(x).toString());console.log(corrcoef(paired).toString());console.log(spearmanr(x, y));