stats
Descriptive statistics over a list of numbers: mean, median, variance, standard deviation and percentiles.
import stats
The stats package works on a Vector<f64> and never changes it. Variance and standard deviation come in two forms: the ordinary one for when the data is a sample of a larger population, dividing by n−1, and the "population" one for when you have the whole population, dividing by n.
Functions
Sum
func Sum(v: Vector<f64>): f64import stats
func main:
mut scores := Vector {} as Vector<f64>
defer scores.free()
each s in [12.0, 18.0, 15.0, 19.0, 11.0]:
scores.push(s)
end
println stats.Sum(scores), stats.Mean(scores), stats.Median(scores)
println stats.Min(scores), stats.Max(scores)
println stats.Variance(scores), stats.PopVariance(scores)
println stats.Stdev(scores), stats.PopStdev(scores)
println stats.Geomean(scores), stats.Percentile(scores, 90.0)
endMean
func Mean(v: Vector<f64>): f64The example for this item is shown with the ones above: stats-Mean.salam
Min
func Min(v: Vector<f64>): f64The example for this item is shown with the ones above: stats-Mean.salam
Max
func Max(v: Vector<f64>): f64The example for this item is shown with the ones above: stats-Mean.salam
Median
func Median(v: Vector<f64>): f64The example for this item is shown with the ones above: stats-Mean.salam
Variance
func Variance(v: Vector<f64>): f64The example for this item is shown with the ones above: stats-Mean.salam
PopVariance
func PopVariance(v: Vector<f64>): f64The example for this item is shown with the ones above: stats-Mean.salam
Stdev
func Stdev(v: Vector<f64>): f64The example for this item is shown with the ones above: stats-Mean.salam
PopStdev
func PopStdev(v: Vector<f64>): f64The example for this item is shown with the ones above: stats-Mean.salam
Geomean
func Geomean(v: Vector<f64>): f64The example for this item is shown with the ones above: stats-Mean.salam
Percentile
func Percentile(v: Vector<f64>, p: f64): f64pth percentile, with p between zero and a hundred; the 90th percentile, for instance, is the value 90 per cent of the data falls below.The example for this item is shown with the ones above: stats-Mean.salam