Skip to content

Utility functions for statistical population samples.

License

Notifications You must be signed in to change notification settings

alcortesm/sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc Build Status codecov.io

Sample

Sample is a Go package to calculate useful values from samples of statistical populations, including:

  • the sample mean

  • the sample-based unbiased estimation of the standard deviation of the population

  • the standard error of the mean

  • the confidence intervals of the mean, assuming the samples comes from a Normal distribution of unknown variance

The standard Go float64 type is used in all computations.

This package does not take advantage of multicore architectures.

Import

import "github.com/alcortesm/sample"

Examples

package main

import (
	"fmt"
	"log"

	"github.com/alcortesm/sample"
)

func main() {
	data := []float64{1.1, 0.9, 1.1, 1.3, 1.0}

	// ignoring errors for demonstration purposes
	mean, _ := sample.Mean(data)
	fmt.Println(mean) // 1.08

	sd, _ := sample.StandardDeviation(data)
	fmt.Println(sd) // 0.15

	se, _ := sample.StandardError(data)
	fmt.Println(se) // 0.07

	confidence := 0.95
	ci, _ := sample.MeanConfidenceIntervals(data, confidence)
	fmt.Printf("[%1.2f, %1.2f]\n", ci[0], ci[1]) // [0.90, 1.26]
}

Author

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Utility functions for statistical population samples.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages