Documentation
¶
Overview ¶
Package sample implements some useful functions to process samples from statistical populations. The standard Go `float64` type is used in all computations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrSampleTooSmall = errors.New("too few sample points") ErrInvalidConfidence = errors.New("invalid confidence level, 0 < confidence < 1)") )
ErrSampleTooSmall is returned when the provided data sample set is too small for a computation.
ErrInvalidConfidenceLevel is returned when the confidence level passed to MeanConfidenceIntervals is not in the valid range.
Functions ¶
func Mean ¶
Mean computes the sample mean of a population sample.
If the sample size is less than 1, it returns ErrSampleTooSmall
func MeanConfidenceIntervals ¶
MeanConfidenceIntervals assumes the sample points are from a Normal distribution of unknown variance and calculates the confidence intervals of the mean of the distribution for the given confidence level.
If the sample size is less than 2, it returns ErrSampleTooSmall.
If the confidence value is not in the ]0, 1[ it returns ErrInvalidConfidence.
func StandardDeviation ¶
StandardDeviation computes the sample-based unbiased estimation of the standard deviation of a population.
This implementation uses the Bessel's correction and is downward biassed as per Jensen's inequality.
It is calculated as sqrt(1/(N-1) sum_i_N(x_i-mean(x))).
If the sample size is less than 2, it returns ErrSampleTooSmall
func StandardError ¶
StandardError returns the standard deviation of the sampling distribution of the mean, also known as the "Standard Error of the Mean".
If the sample size is less than 2, it returns ErrSampleTooSmall
Types ¶
This section is empty.
