Documentation ¶
Index ¶
- func Absdev(data Interface) float64
- func AbsdevMean(data Interface, mean float64) float64
- func Covariance(data1, data2 Interface) float64
- func CovarianceMean(data1, data2 Interface, mean1, mean2 float64) float64
- func Kurtosis(data Interface) float64
- func KurtosisMainSd(data Interface, mean, sd float64) float64
- func Lag1Autocorrelation(data Interface) float64
- func Lag1AutocorrelationMean(data Interface, mean float64) float64
- func Max(data Interface) (max float64, max_index int)
- func Mean(data Interface) (mean float64)
- func MedianFromSortedData(sortedData Interface) (median float64)
- func Min(data Interface) (min float64, min_index int)
- func Minmax(data Interface) (min float64, min_index int, max float64, max_index int)
- func PVariance(data1, data2 Interface) float64
- func QuantileFromSortedData(sortedData Interface, f float64) (result float64)
- func Sd(data Interface) float64
- func SdMean(data Interface, mean float64) float64
- func SdWithFixedMean(data Interface, mean float64) float64
- func Skew(data Interface) float64
- func SkewMeanSd(data Interface, mean, sd float64) (skew float64)
- func TTest(data1, data2 Interface) float64
- func Variance(data Interface) float64
- func VarianceMean(data Interface, mean float64) float64
- func VarianceWithFixedMean(data Interface, mean float64) float64
- func WAbsdev(w, data Interface) float64
- func WAbsdevMean(w, data Interface, wmean float64) (wabsdev float64)
- func WKurtosis(w, data Interface) float64
- func WKurtosisMeanSd(w, data Interface, wmean, wsd float64) float64
- func WMean(w, data Interface) (wmean float64)
- func WSd(w, data Interface) float64
- func WSdMean(w, data Interface, wmean float64) float64
- func WSkew(w, data Interface) float64
- func WSkewMeanSd(w, data Interface, wmean, wsd float64) (wskew float64)
- func WVariance(w, data Interface) float64
- func WVarianceMean(w, data Interface, wmean float64) float64
- func WVarianceWithFixedMean(w, data Interface, wmean float64) float64
- func WsdWithFixedMean(w, data Interface, wmean float64) float64
- type Float64
- type Int64
- type Interface
- type Strider
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbsdevMean ¶
AbsdevMean finds the absolute deviation of the data interface
func Covariance ¶
func CovarianceMean ¶
func KurtosisMainSd ¶
func Lag1Autocorrelation ¶
func Lag1AutocorrelationMean ¶
func Max ¶
Max finds the first largest member and the members position within the data
Example ¶
package main import ( "fmt" "github.com/grd/statistics" ) func main() { data := statistics.Float64{17.2, 18.1, 16.5, 18.3, 12.6} largest, index := statistics.Max(&data) fmt.Printf("The largest value is %g and the index is %d", largest, index) }
Output: The largest value is 18.3 and the index is 3
func Mean ¶
Mean calculates the arithmetic mean with the recurrence relation
Example ¶
package main import ( "fmt" "github.com/grd/statistics" ) func main() { data := statistics.Float64{17.2, 18.1, 16.5, 18.3, 12.6} mean := statistics.Mean(&data) fmt.Printf("The sample mean is %g", mean) }
Output: The sample mean is 16.54
func MedianFromSortedData ¶
MedianFromSortedData calculates the median of the sorted data. Note that the function doesn't check wheather the data is actually sorted.
Example ¶
package main import ( "fmt" "github.com/grd/statistics" "sort" ) func main() { data := statistics.Float64{17.2, 18.1, 16.5, 18.3, 12.6} sort.Sort(&data) median := statistics.MedianFromSortedData(&data) fmt.Printf("Sorted dataset: %v\n", data) fmt.Printf("The median is %g\n", median) }
Output: Sorted dataset: [12.6 16.5 17.2 18.1 18.3] The median is 17.2
func Min ¶
Min finds the first smallest member and the members position within the data
Example ¶
package main import ( "fmt" "github.com/grd/statistics" ) func main() { data := statistics.Float64{17.2, 18.1, 16.5, 18.3, 12.6} smallest, index := statistics.Min(&data) fmt.Printf("The smallest value is %g and the index is %d", smallest, index) }
Output: The smallest value is 12.6 and the index is 4
func Minmax ¶
Minmax finds the first smallest and largest members and the members positions within the data
func QuantileFromSortedData ¶
QuantileFromSortedData performs the quantile function, also called percent point function or inverse cumulative distribution function, on the sorted data. Note that the function doesn't check wheather the data is actually sorted.
Example ¶
package main import ( "fmt" "github.com/grd/statistics" "sort" ) func main() { data := statistics.Float64{17.2, 18.1, 16.5, 18.3, 12.6} sort.Sort(&data) upperq := statistics.QuantileFromSortedData(&data, 0.75) lowerq := statistics.QuantileFromSortedData(&data, 0.25) fmt.Printf("Sorted dataset: %v\n", data) fmt.Printf("The upper quartile is %g\n", upperq) fmt.Printf("The lower quartile is %g\n", lowerq) }
Output: Sorted dataset: [12.6 16.5 17.2 18.1 18.3] The upper quartile is 18.1 The lower quartile is 16.5
func SdWithFixedMean ¶
func SkewMeanSd ¶
SkewMeanSd calculates the skewness of a dataset
func TTest ¶
runs a t-test between two datasets representing independent samples. Tests to see if the difference between means of the samples is different from zero.
func Variance ¶
Example ¶
package main import ( "fmt" "github.com/grd/statistics" ) func main() { data := statistics.Float64{17.2, 18.1, 16.5, 18.3, 12.6} variance := statistics.Variance(&data) fmt.Printf("The estimated variance is %.4f", variance) }
Output: The estimated variance is 5.3730
func VarianceMean ¶
func VarianceWithFixedMean ¶
func WAbsdevMean ¶
WAbsdevMean calculates the weighted absolute deviation of a dataset
func WKurtosisMeanSd ¶
WKurtosisMean calculates the kurtosis of a dataset
func WSkewMeanSd ¶
Compute the weighted skewness of a dataset
func WVarianceMean ¶
func WVarianceWithFixedMean ¶
func WsdWithFixedMean ¶
Types ¶
type Interface ¶
type Interface interface { Value(int) float64 SetValue(int, float64) Len() int Less(int, int) bool Swap(int, int) }
Interface is used throughout the package.
type Strider ¶
type Strider struct { Interface // contains filtered or unexported fields }
Strider strides over the data, for sampling purposes.
Example ¶
package main import ( "fmt" "github.com/grd/statistics" ) func main() { data := statistics.Float64{ .0421, .0941, .1064, .0242, .1331, .0773, .0243, .0815, .1186, .0356, .0728, .0999, .0614, .0479} strider := statistics.NewStrider(&data, 4) for i := 0; i < strider.Len(); i++ { fmt.Println(strider.Value(i)) } }
Output: 0.0421 0.1331 0.1186
func NewStrider ¶
Example ¶
package main import ( "fmt" "github.com/grd/statistics" ) func main() { data := statistics.Float64{ .0421, .0941, .1064, .0242, .1331, .0773, .0243, .0815, .1186, .0356, .0728, .0999, .0614, .0479} strider := statistics.NewStrider(&data, 4) fmt.Printf("mean data is %.4f\n", statistics.Mean(&data)) fmt.Printf("mean strider is %.4f\n", statistics.Mean(strider)) }
Output: mean data is 0.0728 mean strider is 0.0979