stats: github.com/montanaflynn/stats Index | Files | Directories

package stats

import "github.com/montanaflynn/stats"

Index

Package Files

correlation.go data.go deviation.go errors.go legacy.go load.go max.go mean.go median.go min.go mode.go outlier.go percentile.go quartile.go regression.go round.go sample.go sum.go util.go variance.go

Variables

var (
    EmptyInput  = statsErr{"Input must not be empty."}
    SampleSize  = statsErr{"Samples number must be less than input length."}
    NaNErr      = statsErr{"Not a number"}
    NegativeErr = statsErr{"Slice must not contain negative values."}
    ZeroErr     = statsErr{"Slice must not contain zero values."}
    BoundsErr   = statsErr{"Input is outside of range."}
    SizeErr     = statsErr{"Slices must be the same length."}
)

These are the package-wide error values. All error identification should use these values.

func Correlation Uses

func Correlation(data1, data2 Float64Data) (float64, error)

Correlation describes the degree of relationship between two sets of data

func Covariance Uses

func Covariance(data1, data2 Float64Data) (float64, error)

Covariance is a measure of how much two sets of data change

func CovariancePopulation Uses

func CovariancePopulation(data1, data2 Float64Data) (float64, error)

CovariancePopulation computes covariance for entire population between two variables.

func ExpReg Uses

func ExpReg(s []Coordinate) (regressions []Coordinate, err error)

ExpReg is a shortcut to ExponentialRegression

func GeometricMean Uses

func GeometricMean(input Float64Data) (float64, error)

GeometricMean gets the geometric mean for a slice of numbers

func HarmonicMean Uses

func HarmonicMean(input Float64Data) (float64, error)

HarmonicMean gets the harmonic mean for a slice of numbers

func InterQuartileRange Uses

func InterQuartileRange(input Float64Data) (float64, error)

InterQuartileRange finds the range between Q1 and Q3

func LinReg Uses

func LinReg(s []Coordinate) (regressions []Coordinate, err error)

LinReg is a shortcut to LinearRegression

func LogReg Uses

func LogReg(s []Coordinate) (regressions []Coordinate, err error)

LogReg is a shortcut to LogarithmicRegression

func Max Uses

func Max(input Float64Data) (max float64, err error)

Max finds the highest number in a slice

func Mean Uses

func Mean(input Float64Data) (float64, error)

Mean gets the average of a slice of numbers

func Median Uses

func Median(input Float64Data) (median float64, err error)

Median gets the median number in a slice of numbers

func MedianAbsoluteDeviation Uses

func MedianAbsoluteDeviation(input Float64Data) (mad float64, err error)

MedianAbsoluteDeviation finds the median of the absolute deviations from the dataset median

func MedianAbsoluteDeviationPopulation Uses

func MedianAbsoluteDeviationPopulation(input Float64Data) (mad float64, err error)

MedianAbsoluteDeviationPopulation finds the median of the absolute deviations from the population median

func Midhinge Uses

func Midhinge(input Float64Data) (float64, error)

Midhinge finds the average of the first and third quartiles

func Min Uses

func Min(input Float64Data) (min float64, err error)

Min finds the lowest number in a set of data

func Mode Uses

func Mode(input Float64Data) (mode []float64, err error)

Mode gets the mode [most frequent value(s)] of a slice of float64s

func Pearson Uses

func Pearson(data1, data2 Float64Data) (float64, error)

Pearson calculates the Pearson product-moment correlation coefficient between two variables.

func Percentile Uses

func Percentile(input Float64Data, percent float64) (percentile float64, err error)

Percentile finds the relative standing in a slice of floats

func PercentileNearestRank Uses

func PercentileNearestRank(input Float64Data, percent float64) (percentile float64, err error)

PercentileNearestRank finds the relative standing in a slice of floats using the Nearest Rank method

func PopulationVariance Uses

func PopulationVariance(input Float64Data) (pvar float64, err error)

PopulationVariance finds the amount of variance within a population

func Round Uses

func Round(input float64, places int) (rounded float64, err error)

Round a float to a specific decimal place or precision

func Sample Uses

func Sample(input Float64Data, takenum int, replacement bool) ([]float64, error)

Sample returns sample from input with replacement or without

func SampleVariance Uses

func SampleVariance(input Float64Data) (svar float64, err error)

SampleVariance finds the amount of variance within a sample

func StandardDeviation Uses

func StandardDeviation(input Float64Data) (sdev float64, err error)

StandardDeviation the amount of variation in the dataset

func StandardDeviationPopulation Uses

func StandardDeviationPopulation(input Float64Data) (sdev float64, err error)

StandardDeviationPopulation finds the amount of variation from the population

func StandardDeviationSample Uses

func StandardDeviationSample(input Float64Data) (sdev float64, err error)

StandardDeviationSample finds the amount of variation from a sample

func StdDevP Uses

func StdDevP(input Float64Data) (sdev float64, err error)

StdDevP is a shortcut to StandardDeviationPopulation

func StdDevS Uses

func StdDevS(input Float64Data) (sdev float64, err error)

StdDevS is a shortcut to StandardDeviationSample

func Sum Uses

func Sum(input Float64Data) (sum float64, err error)

Sum adds all the numbers of a slice together

func Trimean Uses

func Trimean(input Float64Data) (float64, error)

Trimean finds the average of the median and the midhinge

func VarP Uses

func VarP(input Float64Data) (sdev float64, err error)

VarP is a shortcut to PopulationVariance

func VarS Uses

func VarS(input Float64Data) (sdev float64, err error)

VarS is a shortcut to SampleVariance

func Variance Uses

func Variance(input Float64Data) (sdev float64, err error)

Variance the amount of variation in the dataset

type Coordinate Uses

type Coordinate struct {
    X, Y float64
}

Coordinate holds the data in a series

type Float64Data Uses

type Float64Data []float64

Float64Data is a named type for []float64 with helper methods

func LoadRawData Uses

func LoadRawData(raw interface{}) (f Float64Data)

LoadRawData parses and converts a slice of mixed data types to floats

func (Float64Data) Correlation Uses

func (f Float64Data) Correlation(d Float64Data) (float64, error)

Correlation describes the degree of relationship between two sets of data

func (Float64Data) Covariance Uses

func (f Float64Data) Covariance(d Float64Data) (float64, error)

Covariance is a measure of how much two sets of data change

func (Float64Data) CovariancePopulation Uses

func (f Float64Data) CovariancePopulation(d Float64Data) (float64, error)

CovariancePopulation computes covariance for entire population between two variables.

func (Float64Data) GeometricMean Uses

func (f Float64Data) GeometricMean() (float64, error)

GeometricMean returns the median of the data

func (Float64Data) Get Uses

func (f Float64Data) Get(i int) float64

Get item in slice

func (Float64Data) HarmonicMean Uses

func (f Float64Data) HarmonicMean() (float64, error)

HarmonicMean returns the mode of the data

func (Float64Data) InterQuartileRange Uses

func (f Float64Data) InterQuartileRange(d Float64Data) (float64, error)

InterQuartileRange finds the range between Q1 and Q3

func (Float64Data) Len Uses

func (f Float64Data) Len() int

Len returns length of slice

func (Float64Data) Less Uses

func (f Float64Data) Less(i, j int) bool

Less returns if one number is less than another

func (Float64Data) Max Uses

func (f Float64Data) Max() (float64, error)

Max returns the maximum number in the data

func (Float64Data) Mean Uses

func (f Float64Data) Mean() (float64, error)

Mean returns the mean of the data

func (Float64Data) Median Uses

func (f Float64Data) Median() (float64, error)

Median returns the median of the data

func (Float64Data) MedianAbsoluteDeviation Uses

func (f Float64Data) MedianAbsoluteDeviation() (float64, error)

MedianAbsoluteDeviation the median of the absolute deviations from the dataset median

func (Float64Data) MedianAbsoluteDeviationPopulation Uses

func (f Float64Data) MedianAbsoluteDeviationPopulation() (float64, error)

MedianAbsoluteDeviationPopulation finds the median of the absolute deviations from the population median

func (Float64Data) Midhinge Uses

func (f Float64Data) Midhinge(d Float64Data) (float64, error)

Midhinge finds the average of the first and third quartiles

func (Float64Data) Min Uses

func (f Float64Data) Min() (float64, error)

Min returns the minimum number in the data

func (Float64Data) Mode Uses

func (f Float64Data) Mode() ([]float64, error)

Mode returns the mode of the data

func (Float64Data) Pearson Uses

func (f Float64Data) Pearson(d Float64Data) (float64, error)

Pearson calculates the Pearson product-moment correlation coefficient between two variables.

func (Float64Data) Percentile Uses

func (f Float64Data) Percentile(p float64) (float64, error)

Percentile finds the relative standing in a slice of floats

func (Float64Data) PercentileNearestRank Uses

func (f Float64Data) PercentileNearestRank(p float64) (float64, error)

PercentileNearestRank finds the relative standing using the Nearest Rank method

func (Float64Data) PopulationVariance Uses

func (f Float64Data) PopulationVariance() (float64, error)

PopulationVariance finds the amount of variance within a population

func (Float64Data) Quartile Uses

func (f Float64Data) Quartile(d Float64Data) (Quartiles, error)

Quartile returns the three quartile points from a slice of data

func (Float64Data) QuartileOutliers Uses

func (f Float64Data) QuartileOutliers() (Outliers, error)

QuartileOutliers finds the mild and extreme outliers

func (Float64Data) Sample Uses

func (f Float64Data) Sample(n int, r bool) ([]float64, error)

Sample returns sample from input with replacement or without

func (Float64Data) SampleVariance Uses

func (f Float64Data) SampleVariance() (float64, error)

SampleVariance finds the amount of variance within a sample

func (Float64Data) StandardDeviation Uses

func (f Float64Data) StandardDeviation() (float64, error)

StandardDeviation the amount of variation in the dataset

func (Float64Data) StandardDeviationPopulation Uses

func (f Float64Data) StandardDeviationPopulation() (float64, error)

StandardDeviationPopulation finds the amount of variation from the population

func (Float64Data) StandardDeviationSample Uses

func (f Float64Data) StandardDeviationSample() (float64, error)

StandardDeviationSample finds the amount of variation from a sample

func (Float64Data) Sum Uses

func (f Float64Data) Sum() (float64, error)

Sum returns the total of all the numbers in the data

func (Float64Data) Swap Uses

func (f Float64Data) Swap(i, j int)

Swap switches out two numbers in slice

func (Float64Data) Trimean Uses

func (f Float64Data) Trimean(d Float64Data) (float64, error)

Trimean finds the average of the median and the midhinge

func (Float64Data) Variance Uses

func (f Float64Data) Variance() (float64, error)

Variance the amount of variation in the dataset

type Outliers Uses

type Outliers struct {
    Mild    Float64Data
    Extreme Float64Data
}

Outliers holds mild and extreme outliers found in data

func QuartileOutliers Uses

func QuartileOutliers(input Float64Data) (Outliers, error)

QuartileOutliers finds the mild and extreme outliers

type Quartiles Uses

type Quartiles struct {
    Q1  float64
    Q2  float64
    Q3  float64
}

Quartiles holds the three quartile points

func Quartile Uses

func Quartile(input Float64Data) (Quartiles, error)

Quartile returns the three quartile points from a slice of data

type Series Uses

type Series []Coordinate

Series is a container for a series of data

func ExponentialRegression Uses

func ExponentialRegression(s Series) (regressions Series, err error)

ExponentialRegression returns an exponential regression on data series

func LinearRegression Uses

func LinearRegression(s Series) (regressions Series, err error)

LinearRegression finds the least squares linear regression on data series

func LogarithmicRegression Uses

func LogarithmicRegression(s Series) (regressions Series, err error)

LogarithmicRegression returns an logarithmic regression on data series

Directories

PathSynopsis
examples

Package stats imports 5 packages (graph) and is imported by 33 packages. Updated 2017-01-09. Refresh now. Tools for package owners.