norm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: BSD-3-Clause Imports: 6 Imported by: 25

Documentation

Overview

Package norm provides normalization and norm metric computations e.g., L2 = sqrt of sum of squares of a vector.

DivNorm does divisive normalization of elements SubNorm does subtractive normalization of elements ZScore subtracts the mean and divides by the standard deviation

Index

Constants

This section is empty.

Variables

View Source
var KiT_StdNorms = kit.Enums.AddEnum(StdNormsN, kit.NotBitFlag, nil)

Functions

func AddVec32

func AddVec32(a []float32, val float32)

AddVec32 adds scalar to vector

func AddVec64

func AddVec64(a []float64, val float64)

AddVec64 adds scalar to vector

func Binarize32

func Binarize32(a []float32, thr, hiVal, loVal float32)

Binarize32 turns vector into binary-valued, by setting anything >= the threshold to the high value, and everything below to the low value.

func Binarize64

func Binarize64(a []float64, thr, hiVal, loVal float64)

Binarize64 turns vector into binary-valued, by setting anything >= the threshold to the high value, and everything below to the low value.

func DivNorm32

func DivNorm32(a []float32, nfunc Func32)

DivNorm32 does divisive normalization by given norm function i.e., it divides each element by the norm value computed from nfunc.

func DivNorm64

func DivNorm64(a []float64, nfunc Func64)

DivNorm64 does divisive normalization by given norm function i.e., it divides each element by the norm value computed from nfunc.

func L132

func L132(a []float32) float32

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

func L164

func L164(a []float64) float64

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

func L232

func L232(a []float32) float32

L232 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 L264

func L264(a []float64) float64

L264 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 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 MaxIdx32

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

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

func MaxIdx64

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

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

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 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 MinIdx32

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

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

func MinIdx64

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

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

func MultVec32

func MultVec32(a []float32, val float32)

MultVec32 multiplies vector elements by scalar

func MultVec64

func MultVec64(a []float64, val float64)

MultVec64 multiplies vector elements by scalar

func N32

func N32(a []float32) float32

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

func N64

func N64(a []float64) float64

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

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 SubNorm32

func SubNorm32(a []float32, nfunc Func32)

SubNorm32 does subtractive normalization by given norm function i.e., it subtracts norm computed by given function from each element.

func SubNorm64

func SubNorm64(a []float64, nfunc Func64)

SubNorm64 does subtractive normalization by given norm function i.e., it subtracts norm computed by given function from each element.

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 SumSquares32

func SumSquares32(a []float32) float32

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

func SumSquares64

func SumSquares64(a []float64) float64

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

func TensorDivNorm32

func TensorDivNorm32(tsr *etensor.Float32, ndim int, nfunc Func32)

TensorDivNorm32 does divisive normalization by given norm function computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0.

func TensorDivNorm64

func TensorDivNorm64(tsr *etensor.Float64, ndim int, nfunc Func64)

TensorDivNorm64 does divisive normalization by given norm function computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0.

func TensorSubNorm32

func TensorSubNorm32(tsr *etensor.Float32, ndim int, nfunc Func32)

TensorSubNorm32 does subtractive normalization by given norm function computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0 (panics).

func TensorSubNorm64

func TensorSubNorm64(tsr *etensor.Float64, ndim int, nfunc Func64)

TensorSubNorm64 does subtractive normalization by given norm function computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0.

func TensorUnit32

func TensorUnit32(tsr *etensor.Float32, ndim int)

TensorUnit32 subtracts the min and divides by the max, so that values are in 0-1 unit range computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0 (panics).

func TensorUnit64

func TensorUnit64(tsr *etensor.Float64, ndim int)

TensorUnit64 subtracts the min and divides by the max, so that values are in 0-1 unit range computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0 (panics).

func TensorZScore32

func TensorZScore32(tsr *etensor.Float32, ndim int)

TensorZScore32 subtracts the mean and divides by the standard deviation computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0 (panics).

func TensorZScore64

func TensorZScore64(tsr *etensor.Float64, ndim int)

TensorZScore64 subtracts the mean and divides by the standard deviation computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0 (panics).

func Thresh32

func Thresh32(a []float32, hi bool, hiThr float32, lo bool, loThr float32)

Thresh32 thresholds the values of the vector -- anything above the high threshold is set to the high value, and everything below the low threshold is set to the low value.

func Thresh64

func Thresh64(a []float64, hi bool, hiThr float64, lo bool, loThr float64)

Thresh64 thresholds the values of the vector -- anything above the high threshold is set to the high value, and everything below the low threshold is set to the low value.

func Unit32

func Unit32(a []float32)

Unit32 subtracts the min and divides by the max, so that values are in 0-1 unit range

func Unit64

func Unit64(a []float64)

Unit64 subtracts the min and divides by the max, so that values are in 0-1 unit range

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 ZScore32

func ZScore32(a []float32)

ZScore32 subtracts the mean and divides by the standard deviation

func ZScore64

func ZScore64(a []float64)

ZScore64 subtracts the mean and divides by the standard deviation

Types

type Func32

type Func32 func(a []float32) float32

Func32 is a norm function operating on slice of float32 numbers

func StdFunc32

func StdFunc32(std StdNorms) Func32

StdFunc32 returns a standard norm function as specified

type Func64

type Func64 func(a []float64) float64

Func64 is a norm function operating on slices of float64 numbers

func StdFunc64

func StdFunc64(std StdNorms) Func64

StdFunc64 returns a standard norm function as specified

type StdNorms

type StdNorms int

StdNorms are standard norm functions, including stats

const (
	L1 StdNorms = iota
	L2
	SumSquares
	N
	Sum
	Mean
	Var
	Std
	Max
	MaxAbs
	Min
	MinAbs

	StdNormsN
)

func (*StdNorms) FromString

func (i *StdNorms) FromString(s string) error

func (StdNorms) MarshalJSON

func (ev StdNorms) MarshalJSON() ([]byte, error)

func (StdNorms) String

func (i StdNorms) String() string

func (*StdNorms) UnmarshalJSON

func (ev *StdNorms) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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