gostat

package module
v0.0.0-...-8b28157 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

README

Simple mathematical statistics functions

This is a mathematical statistics functions package for the Go language. It builds on top of very helpful Gonum Stat package adding few additional functions.

Build Status Coverage Status GoDoc

Installation

Install:
go get -u github.com/mbogus/gostat
Import:
import "github.com/mbogus/gostat"

License

Apache License Version 2.0 - See LICENSE file for more details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MAD

func MAD(x []float64) float64

MAD returns a median absolute deviation (MAD) product.

The MAD algorithm, a recognized statistical methodology, is a robust analog to a more commonly used outlier technique, which uses standard deviation from the mean. MAD uses deviation from the median, which is less susceptible to distortion caused by outlying values.

MAD is determined by calculating the deviation from the median as follows:

1. subtracting each charge in the distribution from the median charge to determine each respective deviation from the median;

2. the absolute values of the deviations from the median are arrayed in order from lowest to highest and the median of the absolute deviations is determined;

3. the median of the absolute deviations (from the median) is multiplied by the constant of 1.4826;

4. this product is defined as the MAD.

func Median

func Median(x []float64) float64

Median returns the median by arraying the data for a given slice from lowest to highest and identifying the value at which half of the data are higher and half are lower

func MovStdDev

func MovStdDev(x, weights []float64, k int, omitNaNs, trailing, fullWnd bool) []float64

MovStdDev returns moving standard deviation, a slice of local k-point standard deviation values, where each standard deviation is calculated over a sliding window of length k across neighboring elements of x. Set center to true for center moving standard deviation or to false for trailing moving standard deviation.

func Normalize

func Normalize(x, weights []float64) []float64

Normalize is normalizing a set of scores x using the standard deviation. This normalization is known as Z-scores. With elementary algebraic manipulations, it can be shown that a set of Z-score has a mean equal of zero and a standard deviation of one. Therefore, Z-scores constitute an unit free measure which can be used to compare observations measured with different units.

func RollingWindow

func RollingWindow(x []float64, k int, omitNaNs, trailing, fullWnd bool) [][]float64

RollingWindow splits slice x into a sliding window of length k. The window size is automatically truncated at the endpoints when there are not enough elements to fill the window.

- trailing - if there are more windows than length of x, do not select center windows

- omitNaNs - omit NaN values

- fullWnd - discard any window that uses fewer elements than k

func Volatility

func Volatility(x []float64, periodicity float64) float64

Volatility calculates historical volatility as annualized standard deviation of logarithmic returns

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL