Documentation ¶
Overview ¶
Package govector provides a nice vector API for handling numeric types in Go.
Index ¶
- Constants
- func Cor(x, y Vector) (float64, error)
- func Cosine(x, y Vector) (float64, error)
- func DotProduct(x, y Vector) (float64, error)
- func Norm(x Vector, pow float64) float64
- type Vector
- func (x Vector) Abs() Vector
- func (x Vector) Apply(f func(float64) float64) Vector
- func (x Vector) Copy() Vector
- func (x Vector) Cumsum() Vector
- func (x Vector) Diff() Vector
- func (x Vector) Ecdf() func(float64) float64
- func (x Vector) Filter(f func(float64) bool) Vector
- func (x Vector) Len() int
- func (x Vector) Less(i, j int) bool
- func (x Vector) Max() float64
- func (x Vector) Mean() float64
- func (x Vector) MeanVar() (float64, float64)
- func (x Vector) Min() float64
- func (x Vector) Order() Vector
- func (x *Vector) Push(y float64)
- func (x *Vector) PushFixed(y float64) error
- func (x Vector) Quantiles(q Vector) Vector
- func (x Vector) Rank() Vector
- func (x Vector) RelDiff() Vector
- func (x Vector) Round(precision uint) Vector
- func (x Vector) Sample(n int) Vector
- func (x Vector) Sd() float64
- func (x Vector) Shuffle() Vector
- func (x Vector) Smooth(left, right uint) Vector
- func (x Vector) Sort()
- func (x Vector) Subtract(y Vector) (Vector, error)
- func (x Vector) SubtractConst(e float64) Vector
- func (x Vector) Sum() float64
- func (x Vector) Swap(i, j int)
- func (x Vector) Unique() Vector
- func (x Vector) Variance() float64
- func (x Vector) WeightedMean(w Vector) (float64, error)
Constants ¶
const (
NA = math.SmallestNonzeroFloat64
)
Variables ¶
This section is empty.
Functions ¶
func DotProduct ¶
DotProduct returns the dot product of two vectors.
Types ¶
type Vector ¶
type Vector []float64
func (Vector) Apply ¶
Apply returns the values of the vector applied to an arbitrary function, which must return a float64, since a Vector will be returned.
func (Vector) Copy ¶
Copy returns a copy the input vector. This is useful for functions that perform modification and shuffling on the order of the input vector.
func (Vector) Ecdf ¶
Ecdf returns the empirical cumulative distribution function. The ECDF function will return the percentile of a given value relative to the vector.
func (Vector) Filter ¶
Filter returns the values that match the filter function. Vector elements with return values of TRUE are filtered/removed.
func (Vector) Len ¶
Len, Swap, and Less are implemented to allow for direct sorting on Vector types.
func (*Vector) PushFixed ¶
Append values to an array. Array size will not grow if unnecessary. It will grow if the cap has been extended by external modification.
func (Vector) Quantiles ¶
Quantiles returns the quantiles of a vector corresponding to input quantiles using a weighted average approach for index interpolation.
func (Vector) Round ¶
Round returns a vector with all values rounded to a specified precision (decimal places)
func (Vector) Smooth ¶
Smooth takes a sliding window average of vector. Indices i and j refer to the the number of points you'd like to consider before and after a point in the average.
func (Vector) SubtractConst ¶
SubtractConst returns a vector with the differencs between all the values of x and a constant e