Documentation ¶
Index ¶
- Variables
- func Bounds(xs []float64) (min float64, max float64)
- func GeoMean(xs []float64) float64
- func Mean(xs []float64) float64
- func StdDev(xs []float64) float64
- func Variance(xs []float64) float64
- type LocationHypothesis
- type Sample
- func (s Sample) Bounds() (min float64, max float64)
- func (s *Sample) Clear()
- func (s Sample) Copy() *Sample
- func (s *Sample) FilterOutliers()
- func (s Sample) GeoMean() float64
- func (s Sample) IQR() float64
- func (s Sample) Mean() float64
- func (s *Sample) Percentile(pctile float64) float64
- func (s *Sample) Sort() *Sample
- func (s Sample) StdDev() float64
- func (s Sample) Sum() float64
- func (s Sample) Variance() float64
- func (s Sample) Weight() float64
- type TDist
- type TTestResult
- func OneSampleTTest(x TTestSample, μ0 float64, alt LocationHypothesis) (*TTestResult, error)
- func PairedTTest(x1, x2 []float64, μ0 float64, alt LocationHypothesis) (*TTestResult, error)
- func TwoSampleTTest(x1, x2 TTestSample, alt LocationHypothesis) (*TTestResult, error)
- func TwoSampleWelchTTest(x1, x2 TTestSample, alt LocationHypothesis) (*TTestResult, error)
- type TTestSample
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type LocationHypothesis ¶
type LocationHypothesis int
A LocationHypothesis specifies the alternative hypothesis of a location test such as a t-test or a Mann-Whitney U-test. The default (zero) value is to test against the alternative hypothesis that they differ.
const ( // LocationLess specifies the alternative hypothesis that the // location of the first sample is less than the second. This // is a one-tailed test. LocationLess LocationHypothesis = -1 // LocationDiffers specifies the alternative hypothesis that // the locations of the two samples are not equal. This is a // two-tailed test. LocationDiffers LocationHypothesis = 0 // LocationGreater specifies the alternative hypothesis that // the location of the first sample is greater than the // second. This is a one-tailed test. LocationGreater LocationHypothesis = 1 )
type Sample ¶
type Sample struct { // Xs is the slice of sample values. Xs []float64 // Sorted indicates that Xs is sorted in ascending order. Sorted bool }
Sample is a collection of possibly weighted data points.
func (Sample) Bounds ¶
Bounds returns the minimum and maximum values of the Sample.
If the Sample is weighted, this ignores samples with zero weight.
This is constant time if s.Sorted and there are no zero-weighted values.
func (Sample) Copy ¶
Copy returns a copy of the Sample.
The returned Sample shares no data with the original, so they can be modified (for example, sorted) independently.
func (*Sample) FilterOutliers ¶
func (s *Sample) FilterOutliers()
FilterOutliers updates this sample in-place by removing all the values that are outliers
func (Sample) GeoMean ¶
GeoMean returns the geometric mean of the Sample. All samples values must be positive.
func (Sample) IQR ¶
IQR returns the interquartile range of the Sample.
This is constant time if s.Sorted and s.Weights == nil.
func (*Sample) Percentile ¶
Percentile returns the pctileth value from the Sample. This uses interpolation method R8 from Hyndman and Fan (1996).
pctile will be capped to the range [0, 1]. If len(xs) == 0 or all weights are 0, returns NaN.
Percentile(0.5) is the median. Percentile(0.25) and Percentile(0.75) are the first and third quartiles, respectively.
This is constant time if s.Sorted and s.Weights == nil.
func (*Sample) Sort ¶
Sort sorts the samples in place in s and returns s.
A sorted sample improves the performance of some algorithms.
type TDist ¶
type TDist struct {
V float64
}
A TDist is a Student's t-distribution with V degrees of freedom.
type TTestResult ¶
type TTestResult struct {
// N1 and N2 are the sizes of the input samples. For a
// one-sample t-test, N2 is 0.
N1, N2 int
// T is the value of the t-statistic for this t-test.
T float64
// DoF is the degrees of freedom for this t-test.
DoF float64
// AltHypothesis specifies the alternative hypothesis tested
// by this test against the null hypothesis that there is no
// difference in the means of the samples.
AltHypothesis LocationHypothesis
// P is p-value for this t-test for the given null hypothesis.
P float64
}
A TTestResult is the result of a t-test.
func OneSampleTTest ¶
func OneSampleTTest(x TTestSample, μ0 float64, alt LocationHypothesis) (*TTestResult, error)
OneSampleTTest performs a one-sample t-test on sample x. This tests the null hypothesis that the population mean is equal to μ0. This assumes the distribution of the population of sample means is normal.
func PairedTTest ¶
func PairedTTest(x1, x2 []float64, μ0 float64, alt LocationHypothesis) (*TTestResult, error)
PairedTTest performs a two-sample paired t-test on samples x1 and x2. If μ0 is non-zero, this tests if the average of the difference is significantly different from μ0. If x1 and x2 are identical, this returns nil.
func TwoSampleTTest ¶
func TwoSampleTTest(x1, x2 TTestSample, alt LocationHypothesis) (*TTestResult, error)
TwoSampleTTest performs a two-sample (unpaired) Student's t-test on samples x1 and x2. This is a test of the null hypothesis that x1 and x2 are drawn from populations with equal means. It assumes x1 and x2 are independent samples, that the distributions have equal variance, and that the populations are normally distributed.
func TwoSampleWelchTTest ¶
func TwoSampleWelchTTest(x1, x2 TTestSample, alt LocationHypothesis) (*TTestResult, error)
TwoSampleWelchTTest performs a two-sample (unpaired) Welch's t-test on samples x1 and x2. This is like TwoSampleTTest, but does not assume the distributions have equal variance.
type TTestSample ¶
A TTestSample is a sample that can be used for a one or two sample t-test.