Documentation ¶
Overview ¶
Package stat provides statistic functions and types.
Index ¶
- func Apply(s Series, f func(float64) float64)
- func Autocor(s Series, lag int) float64
- func Autocov(s Series, lag int) float64
- func Cor(s, t Series) float64
- func Cov(s, t Series) float64
- func CovP(s, t Series) float64
- func Fold(s Series, a float64, f func(float64, float64) float64) float64
- func Max(s Series) float64
- func Mean(s Series) float64
- func Median(s Series) float64
- func Min(s Series) float64
- func Skew(s Series) float64
- func SkewP(s Series) float64
- func Std(s Series) float64
- func StdP(s Series) float64
- func Var(s Series) float64
- func VarP(s Series) float64
- type Run
- func (r *Run) Add(x float64)
- func (r *Run) AddN(n int64, x float64)
- func (r *Run) Max() float64
- func (r *Run) Mean() float64
- func (r *Run) Min() float64
- func (r *Run) N() int64
- func (r *Run) Reset()
- func (r *Run) Std() float64
- func (r *Run) StdP() float64
- func (r *Run) Var() float64
- func (r *Run) VarP() float64
- type Running
- type Series
- func Add(s, t Series) Series
- func Add1(s Series, f float64) Series
- func Div(s, t Series) Series
- func Div1(s Series, f float64) Series
- func Head(s Series, n int) Series
- func Map(s Series, f func(float64) float64) Series
- func Map2(s, t Series, f func(a, b float64) float64) Series
- func Mul(s, t Series) Series
- func Mul1(s Series, f float64) Series
- func Resize(s Series, n int) Series
- func Sub(s, t Series) Series
- func Sub1(s Series, f float64) Series
- func Tail(s Series, n int) Series
- func (s Series) Add(t Series) Series
- func (s Series) Add1(f float64) Series
- func (s *Series) Append(f ...float64)
- func (s *Series) Append1(f float64)
- func (s Series) Autocor(lag int) float64
- func (s Series) Autocov(lag int) float64
- func (s Series) Copy() Series
- func (s Series) Cor(t Series) float64
- func (s Series) Cov(t Series) float64
- func (s Series) CovP(t Series) float64
- func (s Series) Div(t Series) Series
- func (s Series) Div1(f float64) Series
- func (s Series) Head(n int) Series
- func (s Series) Len() int
- func (s Series) Map(f func(float64) float64) Series
- func (s Series) Max() float64
- func (s Series) Mean() float64
- func (s Series) Median() float64
- func (s Series) Min() float64
- func (s Series) Mul(t Series) Series
- func (s Series) Mul1(f float64) Series
- func (s *Series) Reset()
- func (s Series) Skew() float64
- func (s Series) SkewP() float64
- func (s Series) Std() float64
- func (s Series) StdP() float64
- func (s Series) String() string
- func (s Series) Sub(t Series) Series
- func (s Series) Sub1(f float64) Series
- func (s Series) Tail(n int) Series
- func (s Series) Var() float64
- func (s Series) VarP() float64
- func (s Series) WriteFile(path string) error
- type Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Autocor ¶
Autocor returns the sample correlation of s with itself lag values later. The series s must be at least 2 longer than lag, else NaN is returned.
func Autocov ¶
Autocov returns the sample covariance of s with itself lag values later. The series s must be at least 2 longer than lag, else NaN is returned.
func Cor ¶
Cor returns the sample correlation of two series s and t.
If the series do not have the same lengths, this function panics. If s is empty or has only one element, one cannot speak of variance, and NaN is returned.
NOTE: This is the same as the population correlation of two series, hence there is no CorP.
func Cov ¶
Cov returns the sample covariance of two series s and t.
If the series do not have the same lengths, this function panics. If s is empty or has only one element, one cannot speak of variance, and NaN is returned.
func CovP ¶
CovP returns the population covariance of two series s and t.
If the series do not have the same lengths, this function panics. If s is empty or has only one element, one cannot speak of variance, and NaN is returned.
func Fold ¶
Fold a series into a single value by repeatedly applying a = f(a, x).
For example, to find the maximum value:
Fold(s, math.Inf(-1), math.Max)
func Mean ¶
Mean returns the empirical mean of the series s.
The mean calculated here is the running mean, which ensures that an answer is given regardless of how long s is. The accuracy of the answer suffers however.
If s is empty, NaN is returned.
func Median ¶
Median returns the median of the series s.
If s has an even number of elements, the mean of the two middle elements is returned.
If s is empty or has only one element, NaN is returned.
Calculating the median requires sorting a copy of the series.
func Std ¶
Std returns the sample standard deviation of the series.
If s is empty or has only one element, one cannot speak of variance, and NaN is returned.
func StdP ¶
StdP returns the population standard deviation of the series.
If s is empty or has only one element, one cannot speak of variance, and NaN is returned.
Types ¶
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
Run calculates the running mean, variance, and standard deviation.
Note: Run contains only plain old datatypes, so a shallow copy is a complete copy.
type Running ¶
type Running struct {
// contains filtered or unexported fields
}
Running calculates the running means, variances, and standard deviation over time.
type Series ¶
type Series []float64
The Series type is a slice of float64 values.
func Head ¶
Head returns the first n values from s.
If n > len(s), an out-of-bounds panic will occur. The returned slice is a slice from s, not a new series.
func Map2 ¶
Map creates a new series by applying f to each value in s and t.
If the series lengths are not the same, the function panics.
func Resize ¶
Resize returns s resized to have length n.
If s is empty, the function panics. If n is less than the size of s, the first n elements of s is returned. If n is greater than the size of s, s is appended to s as often as necessary:
Example:
Resize([1 2 3], 5) -> [1 2 3 1 2] Resize([1 2 3 4 5], 3) -> [1 2 3]
func Tail ¶
Tail returns the last n values from s.
If n > len(s), an out-of-bounds panic will occur. The returned slice is a slice from s, not a new series.
Directories ¶
Path | Synopsis |
---|---|
Package dist provides statistical probability distributions for random variables.
|
Package dist provides statistical probability distributions for random variables. |
Package test provides statistical tests, such as the ChiSquaredTest.
|
Package test provides statistical tests, such as the ChiSquaredTest. |