num

package
v0.0.0-...-225e849 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: Apache-2.0 Imports: 4 Imported by: 9

Documentation

Overview

Package num provides various numeric functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToInt

func BoolToInt(b bool) int

BoolToInt converts a boolean to an int, with 1=true 0=false.

func F32SliceToF64

func F32SliceToF64(s []float32) []float64

F32SliceToF64 converts a float32 slice to a float64 slice.

func I32SliceToI

func I32SliceToI(s []int32) []int

I32SliceToI converts an int32 slice to an int slice.

func MakeIRange

func MakeIRange(min, max int) []int

MakeIRange creates an int slice for the given range.

func MaxF32

func MaxF32(vals []float32) (int, float32)

MaxF32 returns the max index and max value for a float32 slice.

func Mean

func Mean(vals []float32) float32

Mean of the values.

func MeanNorm

func MeanNorm(x, min, max, average float32) float32

MeanNorm is mean normalization.

func MinMaxNorm

func MinMaxNorm(x, min, max float32) float32

MinMaxNorm is min-max normalization.

func RandF32

func RandF32(min, max float32) float32

RandF32 returns a random float in the given range.

func StdDev

func StdDev(x []float32) float32

StdDev returns the standard deviation of x.

func ToF32

func ToF32(i interface{}) (float32, error)

ToF32 attempts to convert the given interface to float32.

func ToF64

func ToF64(i interface{}) (float64, error)

ToF64 attempts to convert the given interface to float64.

func Variance

func Variance(vals []float32) float32

Variance is the average distance from the mean.

func ZNorm

func ZNorm(x, mean, stdDev float32) float32

ZNorm uses z-score normalization.

Types

type EqWidthBinner

type EqWidthBinner struct {
	// NumIntervals is the number of bins.
	NumIntervals int

	// High is the upper bound of the continuous space.
	High float32

	// Low is the lower bound of the continuous space.
	Low float32
	// contains filtered or unexported fields
}

EqWidthBinner implements the equal width binning algorithm. This is used to discretize continuous spaces.

func NewEqWidthBinner

func NewEqWidthBinner(numIntervals int, high, low float32) *EqWidthBinner

NewEqWidthBinner returns an EqWidthBin.

func (*EqWidthBinner) Bin

func (e *EqWidthBinner) Bin(v float32) (int, error)

Bin the given value.

Jump to

Keyboard shortcuts

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