statext

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2019 License: MIT Imports: 5 Imported by: 0

README

statext GoDoc Build Status Report Card

Extra probability distributions and statistics utilities for Go

Package statext provides additional probability distributions in gonum format, and statistics utilities.

Currently, this library has:

  • PoissonBinomial: The Poisson binomial distribution, implemented based on gonum's Dirichlet and Binomial distributions. See Wikipedia for more info. Uses a custom hierarchical FFT algorithm to efficiently compute the probabilities in O(n*ln(n)2) time, from gofft.
  • DirichletWinner: A function to compute the probabilities that each output will be the largest when randomly sampling a Dirichlet distribution. Uses a custom adaptive quadrature integration method to efficiently compute the probabilities within a specified tolerance.

More is planned.

License

Original code is licensed under the MIT License found in the LICENSE file. Portions of the code are subject to the additional licenses found in THIRD_PARTY_LICENSES. All third party code is licensed either under a BSD or MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirichletWinner

func DirichletWinner(alphas []float64, tol float64) []float64

DirichletWinner computes the probabilities that each output value of the Dirichlet distribution will be the largest. Uses an adaptive quadrature integration technique with the

Types

type BetaPrime added in v0.2.0

type BetaPrime struct {
	// Alpha is the left shape parameter of the distribution. Alpha must be greater
	// than 0.
	Alpha float64
	// Beta is the right shape parameter of the distribution. Beta must be greater
	// than 0.
	Beta float64

	Src rand.Source
}

BetaPrime implements the BetaPrime distribution, a two-parameter continuous distribution with support over the positive real numbers.

The beta prime distribution has density function

x^(α-1) * (1+x)^(-α-β) * Γ(α+β) / (Γ(α)*Γ(β))

For more information, see https://en.wikipedia.org/wiki/Beta_prime_distribution

func (BetaPrime) CDF added in v0.2.0

func (b BetaPrime) CDF(x float64) float64

CDF computes the value of the cumulative density function at x.

func (BetaPrime) ExKurtosis added in v0.2.0

func (b BetaPrime) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

ExKurtosis returns NaN if the Beta parameter is less or equal to 4.

func (BetaPrime) LogProb added in v0.2.0

func (b BetaPrime) LogProb(x float64) float64

LogProb computes the natural logarithm of the value of the probability density function at x.

func (BetaPrime) Mean added in v0.2.0

func (b BetaPrime) Mean() float64

Mean returns the mean of the probability distribution.

Mean returns NaN if the Beta parameter is less than or equal to 1.

func (BetaPrime) Mode added in v0.2.0

func (b BetaPrime) Mode() float64

Mode returns the mode of the distribution.

Mode returns NaN if the Beta parameter is less than or equal to 1.

func (BetaPrime) NumParameters added in v0.2.0

func (b BetaPrime) NumParameters() int

NumParameters returns the number of parameters in the distribution.

func (BetaPrime) Prob added in v0.2.0

func (b BetaPrime) Prob(x float64) float64

Prob computes the value of the probability density function at x.

func (BetaPrime) Quantile added in v0.2.0

func (b BetaPrime) Quantile(p float64) float64

Quantile returns the inverse of the cumulative distribution function.

func (BetaPrime) Rand added in v0.2.0

func (b BetaPrime) Rand() float64

Rand returns a random sample drawn from the distribution.

func (BetaPrime) Skewness added in v0.2.0

func (b BetaPrime) Skewness() float64

Skewness returns the skewness of the distribution.

Skewness returns NaN if the Beta parameter is less than or equal to 3.

func (BetaPrime) StdDev added in v0.2.0

func (b BetaPrime) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

StdDev returns NaN if the Beta parameter is less than or equal to 2.

func (BetaPrime) Survival added in v0.2.0

func (b BetaPrime) Survival(x float64) float64

Survival returns the survival function (complementary CDF) at x.

func (BetaPrime) Variance added in v0.2.0

func (b BetaPrime) Variance() float64

Variance returns the variance of the probability distribution.

Variance returns NaN if the Beta parameter is less than or equal to 2.

type PoissonBinomial

type PoissonBinomial struct {
	// contains filtered or unexported fields
}

PoissonBinomial represents a random variable whose value is the sum of independent Bernoulli trials that are not necessarily identically distributed. The value of entries in P must be between 0 and 1. More information at https://en.wikipedia.org/wiki/Poisson_binomial_distribution.

func NewPoissonBinomial

func NewPoissonBinomial(p []float64, src rand.Source) PoissonBinomial

NewPoissonBinomial creates a new Poisson binomial distribution with the given parameters p. NewPoissonBinomial will panic if len(p) == 0, or if any p is < 0 or > 1.

func (PoissonBinomial) CDF

func (p PoissonBinomial) CDF(x float64) float64

CDF computes the value of the cumulative distribution function at x.

func (PoissonBinomial) ExKurtosis

func (p PoissonBinomial) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

func (PoissonBinomial) LogProb

func (p PoissonBinomial) LogProb(x float64) float64

LogProb computes the natural logarithm of the value of the probability density function at x.

func (PoissonBinomial) Mean

func (p PoissonBinomial) Mean() float64

Mean returns the mean of the probability distribution.

func (PoissonBinomial) NumParameters

func (p PoissonBinomial) NumParameters() int

NumParameters returns the number of parameters in the distribution.

func (PoissonBinomial) Prob

func (p PoissonBinomial) Prob(x float64) float64

Prob computes the value of the probability density function at x.

func (PoissonBinomial) Rand

func (p PoissonBinomial) Rand() float64

Rand returns a random sample drawn from the distribution.

func (PoissonBinomial) Skewness

func (p PoissonBinomial) Skewness() float64

Skewness returns the skewness of the distribution.

func (PoissonBinomial) StdDev

func (p PoissonBinomial) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

func (PoissonBinomial) Survival

func (p PoissonBinomial) Survival(x float64) float64

Survival returns the survival function (complementary CDF) at x.

func (PoissonBinomial) Variance

func (p PoissonBinomial) Variance() float64

Variance returns the variance of the probability distribution.

Jump to

Keyboard shortcuts

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