tech.v3.datatype.functional

Simple math primitives.

descriptive-statistics

(descriptive-statistics stats v)

Given a sequence of desired stats return a map of statname->value.

Example:

cljs.user> (dfn/descriptive-statistics [:min :max :mean :n-values] (range 10))
{:min 0, :max 9, :mean 4.5, :n-values 10}

distance

(distance x y)

Euclidian distance between x,y

distance-squared

(distance-squared x y)

Euclidian distance squared between x,y

equals

(equals lhs rhs & [error-bar])

Numeric equals - the distance between x,y must be less than error-bar which defaults to 0.001.

magnitude

(magnitude v)

Magnitude of the vector

magnitude-squared

(magnitude-squared v)

Magnitude-squared of the vector

mean

(mean v)

Nan-aware mean. Nan's will be skipped.

median

(median options v)(median v)

Nan-aware median. Nan's will be skipped.

percentiles

(percentiles percentages options v)(percentiles percentages v)

Percentiles are given in whole numbers:

tech.v3.datatype.functional> (percentiles [0 25 50 75 100] (range 10))
[0.0 1.75 4.5 7.25 9.0]

quartiles

(quartiles item)(quartiles options item)

return min, 25 50 75 max of item

reduce-max

(reduce-max v)

Nan-unaware max. tech.v3.datatype.statistics/max is nan-aware

reduce-min

(reduce-min v)

Nan-unaware min. tech.v3.datatype.statistics/min is nan-aware

scalar-eq

(scalar-eq lhs rhs)

NaN-aware eq

shift

(shift rdr n)

Shift by n and fill in with the first element for n>0 or last element for n<0.

Examples:

user> (dfn/shift (range 10) 2)
[0 0 0 1 2 3 4 5 6 7]
user> (dfn/shift (range 10) -2)
[2 3 4 5 6 7 8 9 9 9]

standard-deviation

(standard-deviation v)

Nan-aware standard-deviation. Nan's will be skipped.

sum

(sum v)

Nan-aware sum. Nan's will be skipped.

variance

(variance v)

Nan-aware variance. Nan's will be skipped.