stats

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

README

stats

The stats package provides standard statistic computations operating over floating-point data (both 32 and 64 bit) in the following formats. Each statistic returns a single scalar value summarizing the data in a different way. Some formats also support multi-dimensional tensor data, returning a summary stat for each tensor value, using the outer-most ("row-wise") dimension to summarize over.

  • []float32 and []float64 slices, as e.g., Mean32 and Mean64, skipping any NaN values as missing data.

  • tensor.Float32, tensor.Float64 using the underlying Values slice, and other generic Tensor using the Floats interface (less efficient).

  • table.IndexView indexed views of table.Table data, with *Column functions (e.g., MeanColumn) using names to specify columns, and *Index versions operating on column indexes. Also available for this type are CountIf*, PctIf*, PropIf* functions that return count, percentage, or propoprtion of values according to given function.

Stats

The following statistics are supported (per the Stats enum in stats.go):

  • Count: count of number of elements
  • Sum: sum of elements
  • Prod: product of elements
  • Min: minimum value
  • Max: max maximum value
  • MinAbs: minimum absolute value
  • MaxAbs: maximum absolute value
  • Mean: mean mean value
  • Var: sample variance (squared diffs from mean, divided by n-1)
  • Std: sample standard deviation (sqrt of Var)
  • Sem: sample standard error of the mean (Std divided by sqrt(n))
  • L1Norm: L1 Norm: sum of absolute values
  • SumSq: sum of squared element values
  • L2Norm: L2 Norm: square-root of sum-of-squares
  • VarPop: population variance (squared diffs from mean, divided by n)
  • StdPop: population standard deviation (sqrt of VarPop)
  • SemPop: population standard error of the mean (StdPop divided by sqrt(n))
  • Median: middle value in sorted ordering (only for IndexView)
  • Q1: Q1 first quartile = 25%ile value = .25 quantile value (only for IndexView)
  • Q3: Q3 third quartile = 75%ile value = .75 quantile value (only for IndexView)

Documentation

Overview

Package agg provides aggregation functions operating on IndexView indexed views of table.Table data, along with standard AggFunc functions that can be used at any level of aggregation from tensor on up.

The main functions use names to specify columns, and *Index and *Try versions are available that operate on column indexes and return errors, respectively.

See tsragg package for functions that operate directly on a tensor.Tensor without the indexview indirection.

Index

Constants

This section is empty.

Variables

View Source
var DescStats = []Stats{Count, Mean, Std, Sem, Min, Max, Q1, Median, Q3}

DescStats are all the standard stats

View Source
var DescStatsND = []Stats{Count, Mean, Std, Sem, Min, Max}

DescStatsND are all the standard stats for n-dimensional (n > 1) data -- cannot do quantiles

Functions

func Count32

func Count32(a []float32) float32

Count32 computes the number of non-NaN vector values. Skips NaN's

func Count64

func Count64(a []float64) float64

Count64 computes the number of non-NaN vector values. Skips NaN's

func CountColumn

func CountColumn(ix *table.IndexView, column string) []float64

CountColumn returns the count of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func CountFunc

func CountFunc(idx int, val float64, agg float64) float64

CountFunc is an StatFunc that computes number of elements (non-Null, non-NaN) Use 0 as initial value.

func CountIfColumn

func CountIfColumn(ix *table.IndexView, column string, iffun IfFunc) []float64

CountIfColumn returns the count of true return values for given IfFunc on non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value(s) is size of column cell: 1 for scalar 1D columns and N for higher-dimensional columns.

func CountIfIndex

func CountIfIndex(ix *table.IndexView, colIndex int, iffun IfFunc) []float64

CountIfIndex returns the count of true return values for given IfFunc on non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value(s) is size of column cell: 1 for scalar 1D columns and N for higher-dimensional columns.

func CountIndex

func CountIndex(ix *table.IndexView, colIndex int) []float64

CountIndex returns the count of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func CountTensor

func CountTensor(tsr tensor.Tensor) float64

CountTensor returns the count of non-NaN elements in given Tensor.

func DescAll

func DescAll(ix *table.IndexView) *table.Table

DescAll returns a table of standard descriptive stats for all numeric columns in given table, operating over all non-Null, non-NaN elements in each column.

func DescColumn

func DescColumn(ix *table.IndexView, column string) *table.Table

DescColumn returns a table of standard descriptive aggregates of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned -- use Try version for error message.

func DescColumnTry

func DescColumnTry(ix *table.IndexView, column string) (*table.Table, error)

DescColumnTry returns a table of standard descriptive stats of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, returns error message. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func DescIndex

func DescIndex(ix *table.IndexView, colIndex int) *table.Table

DescIndex returns a table of standard descriptive aggregates of non-Null, non-NaN elements in given IndexView indexed view of an table.Table, for given column index.

func L1Norm32

func L1Norm32(a []float32) float32

L1Norm32 computes the sum of absolute values (L1 Norm). Skips NaN's

func L1Norm64

func L1Norm64(a []float64) float64

L1Norm64 computes the sum of absolute values (L1 Norm). Skips NaN's

func L1NormColumn

func L1NormColumn(ix *table.IndexView, column string) []float64

L1NormColumn returns the L1 norm (sum abs values) of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func L1NormFunc

func L1NormFunc(idx int, val float64, agg float64) float64

L1NormFunc is an StatFunc that computes the L1 norm: sum of absolute values use 0 as initial value.

func L1NormIndex

func L1NormIndex(ix *table.IndexView, colIndex int) []float64

L1NormIndex returns the L1 norm (sum abs values) of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func L1NormTensor

func L1NormTensor(tsr tensor.Tensor) float64

L1NormTensor returns the L1 norm: sum of absolute values of non-NaN elements in given Tensor.

func L2Norm32

func L2Norm32(a []float32) float32

L2Norm32 computes the square-root of sum-of-squares of vector, i.e., the L2 norm. Skips NaN's. Uses optimized algorithm from BLAS that avoids numerical overflow.

func L2Norm64

func L2Norm64(a []float64) float64

L2Norm64 computes the square-root of sum-of-squares of vector, i.e., the L2 norm. Skips NaN's. Uses optimized algorithm from BLAS that avoids numerical overflow.

func L2NormColumn

func L2NormColumn(ix *table.IndexView, column string) []float64

L2NormColumn returns the L2 norm (square root of sum-of-squares) of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func L2NormIndex

func L2NormIndex(ix *table.IndexView, colIndex int) []float64

L2NormIndex returns the L2 norm (square root of sum-of-squares) of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func L2NormTensor

func L2NormTensor(tsr tensor.Tensor) float64

L2NormTensor returns the L2 norm: square root of sum-of-squared values of non-NaN elements in given Tensor.

func Max32

func Max32(a []float32) float32

Max32 computes the max over vector values. Skips NaN's

func Max64

func Max64(a []float64) float64

Max64 computes the max over vector values. Skips NaN's

func MaxAbs32

func MaxAbs32(a []float32) float32

MaxAbs32 computes the max of absolute value over vector values. Skips NaN's

func MaxAbs64

func MaxAbs64(a []float64) float64

MaxAbs64 computes the max over vector values. Skips NaN's

func MaxAbsColumn

func MaxAbsColumn(ix *table.IndexView, column string) []float64

MaxAbsColumn returns the maximum of abs of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MaxAbsFunc

func MaxAbsFunc(idx int, val float64, agg float64) float64

MaxAbsFunc is an StatFunc that computes a max aggregate. use -math.MaxFloat64 for initial agg value.

func MaxAbsIndex

func MaxAbsIndex(ix *table.IndexView, colIndex int) []float64

MaxAbsIndex returns the maximum of abs of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MaxAbsTensor

func MaxAbsTensor(tsr tensor.Tensor) float64

MaxAbsTensor returns the maximum of non-NaN elements in given Tensor.

func MaxColumn

func MaxColumn(ix *table.IndexView, column string) []float64

MaxColumn returns the maximum of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MaxFunc

func MaxFunc(idx int, val float64, agg float64) float64

MaxFunc is an StatFunc that computes a max aggregate. use -math.MaxFloat64 for initial agg value.

func MaxIndex

func MaxIndex(ix *table.IndexView, colIndex int) []float64

MaxIndex returns the maximum of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MaxIndex32

func MaxIndex32(a []float32) (float32, int)

MaxIndex32 computes the max over vector values, and returns index of max as well Skips NaN's

func MaxIndex64

func MaxIndex64(a []float64) (float64, int)

MaxIndex64 computes the max over vector values, and returns index of max as well Skips NaN's

func MaxTensor

func MaxTensor(tsr tensor.Tensor) float64

MaxTensor returns the maximum of non-NaN elements in given Tensor.

func Mean32

func Mean32(a []float32) float32

Mean32 computes the mean of the vector (sum / N). Skips NaN's

func Mean64

func Mean64(a []float64) float64

Mean64 computes the mean of the vector (sum / N). Skips NaN's

func MeanColumn

func MeanColumn(ix *table.IndexView, column string) []float64

MeanColumn returns the mean of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MeanIndex

func MeanIndex(ix *table.IndexView, colIndex int) []float64

MeanIndex returns the mean of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MeanTables

func MeanTables(dts []*table.Table) *table.Table

MeanTables returns an table.Table with the mean values across all float columns of the input tables, which must have the same columns but not necessarily the same number of rows.

func MeanTensor

func MeanTensor(tsr tensor.Tensor) float64

MeanTensor returns the mean of non-NaN elements in given Tensor.

func MedianColumn

func MedianColumn(ix *table.IndexView, column string) []float64

MedianColumn returns the median of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MedianIndex

func MedianIndex(ix *table.IndexView, colIndex int) []float64

MedianIndex returns the median of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func Min32

func Min32(a []float32) float32

Min32 computes the max over vector values. Skips NaN's

func Min64

func Min64(a []float64) float64

Min64 computes the max over vector values. Skips NaN's

func MinAbs32

func MinAbs32(a []float32) float32

MinAbs32 computes the max of absolute value over vector values. Skips NaN's

func MinAbs64

func MinAbs64(a []float64) float64

MinAbs64 computes the max over vector values. Skips NaN's

func MinAbsColumn

func MinAbsColumn(ix *table.IndexView, column string) []float64

MinAbsColumn returns the minimum of abs of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MinAbsFunc

func MinAbsFunc(idx int, val float64, agg float64) float64

MinAbsFunc is an StatFunc that computes a min aggregate. use math.MaxFloat64 for initial agg value.

func MinAbsIndex

func MinAbsIndex(ix *table.IndexView, colIndex int) []float64

MinAbsIndex returns the minimum of abs of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MinAbsTensor

func MinAbsTensor(tsr tensor.Tensor) float64

MinAbsTensor returns the minimum of non-NaN elements in given Tensor.

func MinColumn

func MinColumn(ix *table.IndexView, column string) []float64

MinColumn returns the minimum of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MinFunc

func MinFunc(idx int, val float64, agg float64) float64

MinFunc is an StatFunc that computes a min aggregate. use math.MaxFloat64 for initial agg value.

func MinIndex

func MinIndex(ix *table.IndexView, colIndex int) []float64

MinIndex returns the minimum of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func MinIndex32

func MinIndex32(a []float32) (float32, int)

MinIndex32 computes the min over vector values, and returns index of min as well Skips NaN's

func MinIndex64

func MinIndex64(a []float64) (float64, int)

MinIndex64 computes the min over vector values, and returns index of min as well Skips NaN's

func MinTensor

func MinTensor(tsr tensor.Tensor) float64

MinTensor returns the minimum of non-NaN elements in given Tensor.

func PctIfColumn

func PctIfColumn(ix *table.IndexView, column string, iffun IfFunc) []float64

PctIfColumn returns the percentage (0-100) of true return values for given IfFunc on non-Null, non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned -- use Try version for error message. Return value(s) is size of column cell: 1 for scalar 1D columns and N for higher-dimensional columns.

func PctIfIndex

func PctIfIndex(ix *table.IndexView, colIndex int, iffun IfFunc) []float64

PctIfIndex returns the percentage (0-100) of true return values for given IfFunc on non-Null, non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value(s) is size of column cell: 1 for scalar 1D columns and N for higher-dimensional columns.

func Prod32

func Prod32(a []float32) float32

Prod32 computes the product of vector values. Skips NaN's

func Prod64

func Prod64(a []float64) float64

Prod64 computes the product of vector values. Skips NaN's

func ProdColumn

func ProdColumn(ix *table.IndexView, column string) []float64

ProdColumn returns the product of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func ProdFunc

func ProdFunc(idx int, val float64, agg float64) float64

Prodfunc is an StatFunc that computes a product aggregate. use 1 as initial value.

func ProdIndex

func ProdIndex(ix *table.IndexView, colIndex int) []float64

ProdIndex returns the product of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func ProdTensor

func ProdTensor(tsr tensor.Tensor) float64

ProdTensor returns the product of non-NaN elements in given Tensor.

func PropIfColumn

func PropIfColumn(ix *table.IndexView, column string, iffun IfFunc) []float64

PropIfColumn returns the proportion (0-1) of true return values for given IfFunc on non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned -- use Try version for error message. Return value(s) is size of column cell: 1 for scalar 1D columns and N for higher-dimensional columns.

func PropIfIndex

func PropIfIndex(ix *table.IndexView, colIndex int, iffun IfFunc) []float64

PropIfIndex returns the proportion (0-1) of true return values for given IfFunc on non-Null, non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value(s) is size of column cell: 1 for scalar 1D columns and N for higher-dimensional columns.

func Q1Column

func Q1Column(ix *table.IndexView, column string) []float64

Q1Column returns the first quartile of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func Q1Index

func Q1Index(ix *table.IndexView, colIndex int) []float64

Q1Index returns the first quartile of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func Q3Column

func Q3Column(ix *table.IndexView, column string) []float64

Q3Column returns the third quartile of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func Q3Index

func Q3Index(ix *table.IndexView, colIndex int) []float64

Q3Index returns the third quartile of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func Quantiles

func Quantiles(ix *table.IndexView, column string, qs []float64) []float64

Quantiles returns the given quantile(s) of non-Null, non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned -- use Try version for error message. Column must be a 1d Column -- returns nil for n-dimensional columns. qs are 0-1 values, 0 = min, 1 = max, .5 = median, etc. Uses linear interpolation. Because this requires a sort, it is more efficient to get as many quantiles as needed in one pass.

func QuantilesIndex

func QuantilesIndex(ix *table.IndexView, colIndex int, qs []float64) []float64

QuantilesIndex returns the given quantile(s) of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Column must be a 1d Column -- returns nil for n-dimensional columns. qs are 0-1 values, 0 = min, 1 = max, .5 = median, etc. Uses linear interpolation. Because this requires a sort, it is more efficient to get as many quantiles as needed in one pass.

func Sem32

func Sem32(a []float32) float32

Sem32 returns the sample standard error of the mean of non-NaN elements in vector.

func Sem64

func Sem64(a []float64) float64

Sem64 returns the sample standard error of the mean of non-NaN elements in vector.

func SemColumn

func SemColumn(ix *table.IndexView, column string) []float64

SemColumn returns the sample standard error of the mean of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. Sample sem is normalized by 1/(n-1) -- see SemPop version for 1/n normalization. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func SemIndex

func SemIndex(ix *table.IndexView, colIndex int) []float64

SemIndex returns the sample standard error of the mean of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Sample sem is normalized by 1/(n-1) -- see SemPop version for 1/n normalization. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func SemPop32

func SemPop32(a []float32) float32

SemPop32 returns the population standard error of the mean of non-NaN elements in vector.

func SemPop64

func SemPop64(a []float64) float64

SemPop64 returns the population standard error of the mean of non-NaN elements in vector.

func SemPopColumn

func SemPopColumn(ix *table.IndexView, column string) []float64

SemPopColumn returns the standard error of the mean of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. population sem is normalized by 1/n -- see Var version for 1/(n-1) sample normalization. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func SemPopIndex

func SemPopIndex(ix *table.IndexView, colIndex int) []float64

SemPopIndex returns the population standard error of the mean of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. population sem is normalized by 1/n -- see Var version for 1/(n-1) sample normalization. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func SemPopTensor

func SemPopTensor(tsr tensor.Tensor) float64

SemPopTensor returns the population standard error of the mean of non-NaN elements in given Tensor.

func SemTensor

func SemTensor(tsr tensor.Tensor) float64

SemTensor returns the sample standard error of the mean of non-NaN elements in given Tensor.

func Stat32

func Stat32(a []float32, stat Stats) float32

Stat32 returns statistic according to given Stats type applied to all non-NaN elements in given slice of float32

func Stat64

func Stat64(a []float64, stat Stats) float64

Stat64 returns statistic according to given Stats type applied to all non-NaN elements in given slice of float64

func StatColumn

func StatColumn(ix *table.IndexView, column string, stat Stats) []float64

StatColumn returns IndexView statistic according to given Stats type applied to all non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned -- use Try version for error message. Return value(s) is size of column cell: 1 for scalar 1D columns and N for higher-dimensional columns.

func StatColumnTry

func StatColumnTry(ix *table.IndexView, column string, stat Stats) ([]float64, error)

StatColumnTry returns IndexView statistic according to given Stats type applied to all non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, returns error message. Return value(s) is size of column cell: 1 for scalar 1D columns and N for higher-dimensional columns.

func StatIndex

func StatIndex(ix *table.IndexView, colIndex int, stat Stats) []float64

StatIndex returns IndexView statistic according to given Stats type applied to all non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value(s) is size of column cell: 1 for scalar 1D columns and N for higher-dimensional columns.

func StatIndexFunc

func StatIndexFunc(ix *table.IndexView, colIndex int, ini float64, fun StatFunc) []float64

StatIndexFunc applies given StatFunc function to each element in the given column, using float64 conversions of the values. ini is the initial value for the agg variable. Operates independently over each cell on n-dimensional columns and returns the result as a slice of values per cell.

func StatTensor

func StatTensor(tsr tensor.Tensor, stat Stats) float64

StatTensor returns Tensor statistic according to given Stats type applied to all non-NaN elements in given Tensor

func Std32

func Std32(a []float32) float32

Std32 returns the sample standard deviation of non-NaN elements in vector.

func Std64

func Std64(a []float64) float64

Std64 returns the sample standard deviation of non-NaN elements in vector.

func StdColumn

func StdColumn(ix *table.IndexView, column string) []float64

StdColumn returns the sample std deviation of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. Sample std deviation is normalized by 1/(n-1) -- see StdPop version for 1/n normalization. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func StdIndex

func StdIndex(ix *table.IndexView, colIndex int) []float64

StdIndex returns the sample std deviation of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Sample std deviation is normalized by 1/(n-1) -- see StdPop version for 1/n normalization. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func StdPop32

func StdPop32(a []float32) float32

StdPop32 returns the population standard deviation of non-NaN elements in vector.

func StdPop64

func StdPop64(a []float64) float64

StdPop64 returns the population standard deviation of non-NaN elements in vector.

func StdPopColumn

func StdPopColumn(ix *table.IndexView, column string) []float64

StdPopColumn returns the population std deviation of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. population std dev is normalized by 1/n -- see Var version for 1/(n-1) sample normalization. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func StdPopIndex

func StdPopIndex(ix *table.IndexView, colIndex int) []float64

StdPopIndex returns the population std deviation of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. population std dev is normalized by 1/n -- see Var version for 1/(n-1) sample normalization. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func StdPopTensor

func StdPopTensor(tsr tensor.Tensor) float64

StdPopTensor returns the population standard deviation of non-NaN elements in given Tensor.

func StdTensor

func StdTensor(tsr tensor.Tensor) float64

StdTensor returns the sample standard deviation of non-NaN elements in given Tensor.

func Sum32

func Sum32(a []float32) float32

Sum32 computes the sum of vector values. Skips NaN's

func Sum64

func Sum64(a []float64) float64

Sum64 computes the sum of vector values. Skips NaN's

func SumColumn

func SumColumn(ix *table.IndexView, column string) []float64

SumColumn returns the sum of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func SumFunc

func SumFunc(idx int, val float64, agg float64) float64

SumFunc is an StatFunc that computes a sum aggregate. use 0 as initial value.

func SumIndex

func SumIndex(ix *table.IndexView, colIndex int) []float64

SumIndex returns the sum of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func SumSq32

func SumSq32(a []float32) float32

SumSq32 computes the sum-of-squares of vector. Skips NaN's. Uses optimized algorithm from BLAS that avoids numerical overflow.

func SumSq64

func SumSq64(a []float64) float64

SumSq64 computes the sum-of-squares of vector. Skips NaN's. Uses optimized algorithm from BLAS that avoids numerical overflow.

func SumSqColumn

func SumSqColumn(ix *table.IndexView, column string) []float64

SumSqColumn returns the sum-of-squares of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func SumSqIndex

func SumSqIndex(ix *table.IndexView, colIndex int) []float64

SumSqIndex returns the sum-of-squares of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func SumSqTensor

func SumSqTensor(tsr tensor.Tensor) float64

SumSqTensor returns the sum-of-squares of non-NaN elements in given Tensor.

func SumTensor

func SumTensor(tsr tensor.Tensor) float64

SumTensor returns the sum of non-NaN elements in given Tensor.

func TensorStat

func TensorStat(tsr tensor.Tensor, ini float64, fun StatFunc) float64

TensorStat applies given StatFunc function to each element in the tensor (automatically skips NaN elements), using float64 conversions of the values. ini is the initial value for the agg variable. returns final aggregate value

func Var32

func Var32(a []float32) float32

Var32 returns the sample variance of non-NaN elements.

func Var64

func Var64(a []float64) float64

Var64 returns the sample variance of non-NaN elements.

func VarColumn

func VarColumn(ix *table.IndexView, column string) []float64

VarColumn returns the sample variance of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. Sample variance is normalized by 1/(n-1) -- see VarPop version for 1/n normalization. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func VarIndex

func VarIndex(ix *table.IndexView, colIndex int) []float64

VarIndex returns the sample variance of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. Sample variance is normalized by 1/(n-1) -- see VarPop version for 1/n normalization. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func VarPop32

func VarPop32(a []float32) float32

VarPop32 returns the population variance of non-NaN elements.

func VarPop64

func VarPop64(a []float64) float64

VarPop64 returns the population variance of non-NaN elements.

func VarPopColumn

func VarPopColumn(ix *table.IndexView, column string) []float64

VarPopColumn returns the population variance of non-NaN elements in given IndexView indexed view of an table.Table, for given column name. population variance is normalized by 1/n -- see Var version for 1/(n-1) sample normalization. If name not found, nil is returned. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func VarPopIndex

func VarPopIndex(ix *table.IndexView, colIndex int) []float64

VarPopIndex returns the population variance of non-NaN elements in given IndexView indexed view of an table.Table, for given column index. population variance is normalized by 1/n -- see Var version for 1/(n-1) sample normalization. Return value is size of each column cell -- 1 for scalar 1D columns and N for higher-dimensional columns.

func VarPopTensor

func VarPopTensor(tsr tensor.Tensor) float64

VarPopTensor returns the population variance of non-NaN elements in given Tensor.

func VarTensor

func VarTensor(tsr tensor.Tensor) float64

VarTensor returns the sample variance of non-NaN elements in given Tensor.

Types

type IfFunc

type IfFunc func(idx int, val float64) bool

IfFunc is used for the *If aggregators -- counted if it returns true

type IndexViewFuncColumn

type IndexViewFuncColumn func(ix *table.IndexView, column string) []float64

IndexViewFuncColumn is a stats function operating on IndexView, taking a column name arg

type IndexViewFuncIndex

type IndexViewFuncIndex func(ix *table.IndexView, colIndex int) []float64

IndexViewFuncIndex is a stats function operating on IndexView, taking a column index arg

type StatFunc

type StatFunc func(idx int, val float64, agg float64) float64

StatFunc is an statistic function that incrementally updates agg aggregation value from each element in the tensor in turn. Returns new agg value that will be passed into next item as agg.

type Stats

type Stats int32 //enums:enum

Stats is a list of different standard aggregation functions, which can be used to choose an aggregation function

const (
	// count of number of elements
	Count Stats = iota

	// sum of elements
	Sum

	// product of elements
	Prod

	// minimum value
	Min

	// max maximum value
	Max

	// minimum absolute value
	MinAbs

	// maximum absolute value
	MaxAbs

	// mean mean value
	Mean

	// sample variance (squared diffs from mean, divided by n-1)
	Var

	// sample standard deviation (sqrt of Var)
	Std

	// sample standard error of the mean (Std divided by sqrt(n))
	Sem

	// L1 Norm: sum of absolute values
	L1Norm

	// sum of squared values
	SumSq

	// L2 Norm: square-root of sum-of-squares
	L2Norm

	// population variance (squared diffs from mean, divided by n)
	VarPop

	// population standard deviation (sqrt of VarPop)
	StdPop

	// population standard error of the mean (StdPop divided by sqrt(n))
	SemPop

	// middle value in sorted ordering
	Median

	// Q1 first quartile = 25%ile value = .25 quantile value
	Q1

	// Q3 third quartile = 75%ile value = .75 quantile value
	Q3
)
const StatsN Stats = 20

StatsN is the highest valid value for type Stats, plus one.

func StatsValues

func StatsValues() []Stats

StatsValues returns all possible values for the type Stats.

func (Stats) Desc

func (i Stats) Desc() string

Desc returns the description of the Stats value.

func (Stats) Int64

func (i Stats) Int64() int64

Int64 returns the Stats value as an int64.

func (Stats) MarshalText

func (i Stats) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Stats) SetInt64

func (i *Stats) SetInt64(in int64)

SetInt64 sets the Stats value from an int64.

func (*Stats) SetString

func (i *Stats) SetString(s string) error

SetString sets the Stats value from its string representation, and returns an error if the string is invalid.

func (Stats) String

func (i Stats) String() string

String returns the string representation of this Stats value.

func (*Stats) UnmarshalText

func (i *Stats) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Stats) Values

func (i Stats) Values() []enums.Enum

Values returns all possible values for the type Stats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL