Liking cljdoc? Tell your friends :D

datajure.stat

Statistical transform functions for use inside #dt/e expressions.

These functions operate on column vectors (dtype readers) and return a column of the same length. They are the runtime implementations for stat/* symbols parsed by datajure.expr.

All functions are nil-safe: nil values in the input are skipped when computing reference statistics (mean, sd, percentiles), and nil inputs produce nil outputs in the returned column.

Statistical transform functions for use inside #dt/e expressions.

These functions operate on column vectors (dtype readers) and return a
column of the same length. They are the runtime implementations for
stat/* symbols parsed by datajure.expr.

All functions are nil-safe: nil values in the input are skipped when
computing reference statistics (mean, sd, percentiles), and nil inputs
produce nil outputs in the returned column.
raw docstring

stat-demeanclj

(stat-demean col)

Demean a column: x - mean(x), element-wise. nil values are preserved as nil.

Demean a column: x - mean(x), element-wise.
nil values are preserved as nil.
sourceraw docstring

stat-rescaleclj

(stat-rescale col)
(stat-rescale col new-lo new-hi)

Linearly rescale a column to the range [new-lo, new-hi] (min-max scaling; default [0.0, 1.0]): new-lo + (x - min) / (max - min) * (new-hi - new-lo). min/max are taken over the column's non-nil values. nil values are preserved as nil. A constant column (max = min) has no defined scale and returns all nil, matching standardize's zero-sd behavior. Examples: (stat/rescale :x) → [0,1]; (stat/rescale :x -1 1) → [-1,1].

Linearly rescale a column to the range [new-lo, new-hi] (min-max scaling;
default [0.0, 1.0]): new-lo + (x - min) / (max - min) * (new-hi - new-lo).
min/max are taken over the column's non-nil values. nil values are preserved
as nil. A constant column (max = min) has no defined scale and returns all
nil, matching standardize's zero-sd behavior.
Examples: (stat/rescale :x) → [0,1]; (stat/rescale :x -1 1) → [-1,1].
sourceraw docstring

stat-standardizeclj

(stat-standardize col)

Standardize a column: (x - mean) / sd, element-wise. nil values are preserved as nil. Returns nil for entire column if sd is zero.

Standardize a column: (x - mean) / sd, element-wise.
nil values are preserved as nil. Returns nil for entire column if sd is zero.
sourceraw docstring

stat-trimclj

(stat-trim col p)

Trim a column at the given tail probability p (0 < p < 0.5): values below the p-th percentile or above the (1-p)-th percentile become nil (removed, not clipped — the trimming counterpart of stat-winsorize). Values equal to a percentile bound are kept. nil values stay nil; NaN/±Inf compare false against the bounds and are trimmed to nil. Example: (stat/trim :ret 0.01) nils out the bottom and top 1%.

Trim a column at the given tail probability p (0 < p < 0.5): values below
the p-th percentile or above the (1-p)-th percentile become nil (removed,
not clipped — the trimming counterpart of [[stat-winsorize]]). Values equal
to a percentile bound are kept. nil values stay nil; NaN/±Inf compare false
against the bounds and are trimmed to nil.
Example: (stat/trim :ret 0.01) nils out the bottom and top 1%.
sourceraw docstring

stat-winsorizeclj

(stat-winsorize col p)
(stat-winsorize col p opts)

Winsorize a column at the given tail probability p (0 < p < 0.5). Values below the p-th percentile are clipped to that percentile; values above the (1-p)-th percentile are clipped to that percentile. nil values are preserved as nil.

An optional trailing options map restricts clipping to one tail (mbmisc winsor.bm / winsor.tp): {:tail :lower} clips only the bottom p, {:tail :upper} only the top p; the default is {:tail :both}.

Examples: (stat/winsorize :ret 0.01) clips the bottom and top 1%; (stat/winsorize :ret 0.01 {:tail :upper}) clips only the top 1%.

Winsorize a column at the given tail probability p (0 < p < 0.5).
Values below the p-th percentile are clipped to that percentile;
values above the (1-p)-th percentile are clipped to that percentile.
nil values are preserved as nil.

An optional trailing options map restricts clipping to one tail
(mbmisc winsor.bm / winsor.tp): {:tail :lower} clips only the bottom p,
{:tail :upper} only the top p; the default is {:tail :both}.

Examples: (stat/winsorize :ret 0.01) clips the bottom and top 1%;
(stat/winsorize :ret 0.01 {:tail :upper}) clips only the top 1%.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close