Documentation ¶
Overview ¶
Package distuv provides univariate random distribution types.
Index ¶
- Variables
- type AlphaStable
- func (a AlphaStable) ExKurtosis() float64
- func (a AlphaStable) Mean() float64
- func (a AlphaStable) Median() float64
- func (a AlphaStable) Mode() float64
- func (a AlphaStable) NumParameters() int
- func (a AlphaStable) Rand() float64
- func (a AlphaStable) Skewness() float64
- func (a AlphaStable) StdDev() float64
- func (a AlphaStable) Variance() float64
- type Bernoulli
- func (b Bernoulli) CDF(x float64) float64
- func (b Bernoulli) Entropy() float64
- func (b Bernoulli) ExKurtosis() float64
- func (b Bernoulli) LogProb(x float64) float64
- func (b Bernoulli) Mean() float64
- func (b Bernoulli) Median() float64
- func (Bernoulli) NumParameters() int
- func (b Bernoulli) Prob(x float64) float64
- func (b Bernoulli) Quantile(p float64) float64
- func (b Bernoulli) Rand() float64
- func (b Bernoulli) Skewness() float64
- func (b Bernoulli) StdDev() float64
- func (b Bernoulli) Survival(x float64) float64
- func (b Bernoulli) Variance() float64
- type Beta
- func (b Beta) CDF(x float64) float64
- func (b Beta) Entropy() float64
- func (b Beta) ExKurtosis() float64
- func (b Beta) LogProb(x float64) float64
- func (b Beta) Mean() float64
- func (b Beta) Mode() float64
- func (b Beta) NumParameters() int
- func (b Beta) Prob(x float64) float64
- func (b Beta) Quantile(p float64) float64
- func (b Beta) Rand() float64
- func (b Beta) StdDev() float64
- func (b Beta) Survival(x float64) float64
- func (b Beta) Variance() float64
- type Bhattacharyya
- type Binomial
- func (b Binomial) CDF(x float64) float64
- func (b Binomial) ExKurtosis() float64
- func (b Binomial) LogProb(x float64) float64
- func (b Binomial) Mean() float64
- func (Binomial) NumParameters() int
- func (b Binomial) Prob(x float64) float64
- func (b Binomial) Rand() float64
- func (b Binomial) Skewness() float64
- func (b Binomial) StdDev() float64
- func (b Binomial) Survival(x float64) float64
- func (b Binomial) Variance() float64
- type Categorical
- func (c Categorical) CDF(x float64) float64
- func (c Categorical) Entropy() float64
- func (c Categorical) Len() int
- func (c Categorical) LogProb(x float64) float64
- func (c Categorical) Mean() float64
- func (c Categorical) Prob(x float64) float64
- func (c Categorical) Rand() float64
- func (c Categorical) Reweight(idx int, w float64)
- func (c Categorical) ReweightAll(w []float64)
- type Chi
- func (c Chi) CDF(x float64) float64
- func (c Chi) Entropy() float64
- func (c Chi) ExKurtosis() float64
- func (c Chi) LogProb(x float64) float64
- func (c Chi) Mean() float64
- func (c Chi) Median() float64
- func (c Chi) Mode() float64
- func (c Chi) NumParameters() int
- func (c Chi) Prob(x float64) float64
- func (c Chi) Quantile(p float64) float64
- func (c Chi) Rand() float64
- func (c Chi) Skewness() float64
- func (c Chi) StdDev() float64
- func (c Chi) Survival(x float64) float64
- func (c Chi) Variance() float64
- type ChiSquared
- func (c ChiSquared) CDF(x float64) float64
- func (c ChiSquared) ExKurtosis() float64
- func (c ChiSquared) LogProb(x float64) float64
- func (c ChiSquared) Mean() float64
- func (c ChiSquared) Mode() float64
- func (c ChiSquared) NumParameters() int
- func (c ChiSquared) Prob(x float64) float64
- func (c ChiSquared) Quantile(p float64) float64
- func (c ChiSquared) Rand() float64
- func (c ChiSquared) StdDev() float64
- func (c ChiSquared) Survival(x float64) float64
- func (c ChiSquared) Variance() float64
- type Exponential
- func (e Exponential) CDF(x float64) float64
- func (e *Exponential) ConjugateUpdate(suffStat []float64, nSamples float64, priorStrength []float64)
- func (e Exponential) Entropy() float64
- func (Exponential) ExKurtosis() float64
- func (e *Exponential) Fit(samples, weights []float64)
- func (e Exponential) LogProb(x float64) float64
- func (e Exponential) Mean() float64
- func (e Exponential) Median() float64
- func (Exponential) Mode() float64
- func (Exponential) NumParameters() int
- func (Exponential) NumSuffStat() int
- func (e Exponential) Prob(x float64) float64
- func (e Exponential) Quantile(p float64) float64
- func (e Exponential) Rand() float64
- func (e Exponential) Score(deriv []float64, x float64) []float64
- func (e Exponential) ScoreInput(x float64) float64
- func (Exponential) Skewness() float64
- func (e Exponential) StdDev() float64
- func (Exponential) SuffStat(suffStat, samples, weights []float64) (nSamples float64)
- func (e Exponential) Survival(x float64) float64
- func (e Exponential) Variance() float64
- type F
- func (f F) CDF(x float64) float64
- func (f F) ExKurtosis() float64
- func (f F) LogProb(x float64) float64
- func (f F) Mean() float64
- func (f F) Mode() float64
- func (f F) NumParameters() int
- func (f F) Prob(x float64) float64
- func (f F) Quantile(p float64) float64
- func (f F) Rand() float64
- func (f F) Skewness() float64
- func (f F) StdDev() float64
- func (f F) Survival(x float64) float64
- func (f F) Variance() float64
- type Gamma
- func (g Gamma) CDF(x float64) float64
- func (g Gamma) ExKurtosis() float64
- func (g Gamma) LogProb(x float64) float64
- func (g Gamma) Mean() float64
- func (g Gamma) Mode() float64
- func (Gamma) NumParameters() int
- func (g Gamma) Prob(x float64) float64
- func (g Gamma) Quantile(p float64) float64
- func (g Gamma) Rand() float64
- func (g Gamma) StdDev() float64
- func (g Gamma) Survival(x float64) float64
- func (g Gamma) Variance() float64
- type GumbelRight
- func (g GumbelRight) CDF(x float64) float64
- func (g GumbelRight) Entropy() float64
- func (g GumbelRight) ExKurtosis() float64
- func (g GumbelRight) LogProb(x float64) float64
- func (g GumbelRight) Mean() float64
- func (g GumbelRight) Median() float64
- func (g GumbelRight) Mode() float64
- func (GumbelRight) NumParameters() int
- func (g GumbelRight) Prob(x float64) float64
- func (g GumbelRight) Quantile(p float64) float64
- func (g GumbelRight) Rand() float64
- func (GumbelRight) Skewness() float64
- func (g GumbelRight) StdDev() float64
- func (g GumbelRight) Survival(x float64) float64
- func (g GumbelRight) Variance() float64
- type Hellinger
- type InverseGamma
- func (g InverseGamma) CDF(x float64) float64
- func (g InverseGamma) ExKurtosis() float64
- func (g InverseGamma) LogProb(x float64) float64
- func (g InverseGamma) Mean() float64
- func (g InverseGamma) Mode() float64
- func (InverseGamma) NumParameters() int
- func (g InverseGamma) Prob(x float64) float64
- func (g InverseGamma) Quantile(p float64) float64
- func (g InverseGamma) Rand() float64
- func (g InverseGamma) StdDev() float64
- func (g InverseGamma) Survival(x float64) float64
- func (g InverseGamma) Variance() float64
- type KullbackLeibler
- type Laplace
- func (l Laplace) CDF(x float64) float64
- func (l Laplace) Entropy() float64
- func (l Laplace) ExKurtosis() float64
- func (l *Laplace) Fit(samples, weights []float64)
- func (l Laplace) LogProb(x float64) float64
- func (l Laplace) Mean() float64
- func (l Laplace) Median() float64
- func (l Laplace) Mode() float64
- func (l Laplace) NumParameters() int
- func (l Laplace) Prob(x float64) float64
- func (l Laplace) Quantile(p float64) float64
- func (l Laplace) Rand() float64
- func (l Laplace) Score(deriv []float64, x float64) []float64
- func (l Laplace) ScoreInput(x float64) float64
- func (Laplace) Skewness() float64
- func (l Laplace) StdDev() float64
- func (l Laplace) Survival(x float64) float64
- func (l Laplace) Variance() float64
- type LogNormal
- func (l LogNormal) CDF(x float64) float64
- func (l LogNormal) Entropy() float64
- func (l LogNormal) ExKurtosis() float64
- func (l LogNormal) LogProb(x float64) float64
- func (l LogNormal) Mean() float64
- func (l LogNormal) Median() float64
- func (l LogNormal) Mode() float64
- func (LogNormal) NumParameters() int
- func (l LogNormal) Prob(x float64) float64
- func (l LogNormal) Quantile(p float64) float64
- func (l LogNormal) Rand() float64
- func (l LogNormal) Skewness() float64
- func (l LogNormal) StdDev() float64
- func (l LogNormal) Survival(x float64) float64
- func (l LogNormal) Variance() float64
- type LogProber
- type Logistic
- func (l Logistic) CDF(x float64) float64
- func (l Logistic) ExKurtosis() float64
- func (l Logistic) LogProb(x float64) float64
- func (l Logistic) Mean() float64
- func (l Logistic) Median() float64
- func (l Logistic) Mode() float64
- func (l Logistic) NumParameters() int
- func (l Logistic) Prob(x float64) float64
- func (l Logistic) Quantile(p float64) float64
- func (l Logistic) Skewness() float64
- func (l Logistic) StdDev() float64
- func (l Logistic) Survival(x float64) float64
- func (l Logistic) Variance() float64
- type Normal
- func (n Normal) CDF(x float64) float64
- func (n *Normal) ConjugateUpdate(suffStat []float64, nSamples float64, priorStrength []float64)
- func (n Normal) Entropy() float64
- func (Normal) ExKurtosis() float64
- func (n *Normal) Fit(samples, weights []float64)
- func (n Normal) LogProb(x float64) float64
- func (n Normal) Mean() float64
- func (n Normal) Median() float64
- func (n Normal) Mode() float64
- func (Normal) NumParameters() int
- func (Normal) NumSuffStat() int
- func (n Normal) Prob(x float64) float64
- func (n Normal) Quantile(p float64) float64
- func (n Normal) Rand() float64
- func (n Normal) Score(deriv []float64, x float64) []float64
- func (n Normal) ScoreInput(x float64) float64
- func (Normal) Skewness() float64
- func (n Normal) StdDev() float64
- func (Normal) SuffStat(suffStat, samples, weights []float64) (nSamples float64)
- func (n Normal) Survival(x float64) float64
- func (n Normal) Variance() float64
- type Parameter
- type Pareto
- func (p Pareto) CDF(x float64) float64
- func (p Pareto) Entropy() float64
- func (p Pareto) ExKurtosis() float64
- func (p Pareto) LogProb(x float64) float64
- func (p Pareto) Mean() float64
- func (p Pareto) Median() float64
- func (p Pareto) Mode() float64
- func (p Pareto) NumParameters() int
- func (p Pareto) Prob(x float64) float64
- func (p Pareto) Quantile(prob float64) float64
- func (p Pareto) Rand() float64
- func (p Pareto) StdDev() float64
- func (p Pareto) Survival(x float64) float64
- func (p Pareto) Variance() float64
- type Poisson
- func (p Poisson) CDF(x float64) float64
- func (p Poisson) ExKurtosis() float64
- func (p Poisson) LogProb(x float64) float64
- func (p Poisson) Mean() float64
- func (Poisson) NumParameters() int
- func (p Poisson) Prob(x float64) float64
- func (p Poisson) Rand() float64
- func (p Poisson) Skewness() float64
- func (p Poisson) StdDev() float64
- func (p Poisson) Survival(x float64) float64
- func (p Poisson) Variance() float64
- type Quantiler
- type RandLogProber
- type Rander
- type StudentsT
- func (s StudentsT) CDF(x float64) float64
- func (s StudentsT) LogProb(x float64) float64
- func (s StudentsT) Mean() float64
- func (s StudentsT) Mode() float64
- func (StudentsT) NumParameters() int
- func (s StudentsT) Prob(x float64) float64
- func (s StudentsT) Quantile(p float64) float64
- func (s StudentsT) Rand() float64
- func (s StudentsT) StdDev() float64
- func (s StudentsT) Survival(x float64) float64
- func (s StudentsT) Variance() float64
- type Triangle
- func (t Triangle) CDF(x float64) float64
- func (t Triangle) Entropy() float64
- func (Triangle) ExKurtosis() float64
- func (t Triangle) LogProb(x float64) float64
- func (t Triangle) Mean() float64
- func (t Triangle) Median() float64
- func (t Triangle) Mode() float64
- func (Triangle) NumParameters() int
- func (t Triangle) Prob(x float64) float64
- func (t Triangle) Quantile(p float64) float64
- func (t Triangle) Rand() float64
- func (t Triangle) Score(deriv []float64, x float64) []float64
- func (t Triangle) ScoreInput(x float64) float64
- func (t Triangle) Skewness() float64
- func (t Triangle) StdDev() float64
- func (t Triangle) Survival(x float64) float64
- func (t Triangle) Variance() float64
- type Uniform
- func (u Uniform) CDF(x float64) float64
- func (u Uniform) Entropy() float64
- func (Uniform) ExKurtosis() float64
- func (u Uniform) LogProb(x float64) float64
- func (u Uniform) Mean() float64
- func (u Uniform) Median() float64
- func (Uniform) NumParameters() int
- func (u Uniform) Prob(x float64) float64
- func (u Uniform) Quantile(p float64) float64
- func (u Uniform) Rand() float64
- func (u Uniform) Score(deriv []float64, x float64) []float64
- func (u Uniform) ScoreInput(x float64) float64
- func (Uniform) Skewness() float64
- func (u Uniform) StdDev() float64
- func (u Uniform) Survival(x float64) float64
- func (u Uniform) Variance() float64
- type Weibull
- func (w Weibull) CDF(x float64) float64
- func (w Weibull) Entropy() float64
- func (w Weibull) ExKurtosis() float64
- func (w Weibull) LogProb(x float64) float64
- func (w Weibull) LogSurvival(x float64) float64
- func (w Weibull) Mean() float64
- func (w Weibull) Median() float64
- func (w Weibull) Mode() float64
- func (Weibull) NumParameters() int
- func (w Weibull) Prob(x float64) float64
- func (w Weibull) Quantile(p float64) float64
- func (w Weibull) Rand() float64
- func (w Weibull) Score(deriv []float64, x float64) []float64
- func (w Weibull) ScoreInput(x float64) float64
- func (w Weibull) Skewness() float64
- func (w Weibull) StdDev() float64
- func (w Weibull) Survival(x float64) float64
- func (w Weibull) Variance() float64
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var UnitNormal = Normal{Mu: 0, Sigma: 1}
UnitNormal is an instantiation of the normal distribution with Mu = 0 and Sigma = 1.
var UnitUniform = Uniform{Min: 0, Max: 1}
UnitUniform is an instantiation of the uniform distribution with Min = 0 and Max = 1.
Functions ¶
This section is empty.
Types ¶
type AlphaStable ¶ added in v0.8.0
type AlphaStable struct { // Alpha is the stability parameter. // It is valid within the range 0 < α ≤ 2. Alpha float64 // Beta is the skewness parameter. // It is valid within the range -1 ≤ β ≤ 1. Beta float64 // C is the scale parameter. // It is valid when positive. C float64 // Mu is the location parameter. Mu float64 Src rand.Source }
AlphaStable represents an α-stable distribution with four parameters. See https://en.wikipedia.org/wiki/Stable_distribution for more information.
func (AlphaStable) ExKurtosis ¶ added in v0.8.0
func (a AlphaStable) ExKurtosis() float64
ExKurtosis returns the excess kurtosis of the distribution. ExKurtosis returns NaN when Alpha != 2.
func (AlphaStable) Mean ¶ added in v0.8.0
func (a AlphaStable) Mean() float64
Mean returns the mean of the probability distribution. Mean returns NaN when Alpha <= 1.
func (AlphaStable) Median ¶ added in v0.8.0
func (a AlphaStable) Median() float64
Median returns the median of the distribution. Median panics when Beta != 0, because then the mode is not analytically expressible.
func (AlphaStable) Mode ¶ added in v0.8.0
func (a AlphaStable) Mode() float64
Mode returns the mode of the distribution. Mode panics when Beta != 0, because then the mode is not analytically expressible.
func (AlphaStable) NumParameters ¶ added in v0.8.0
func (a AlphaStable) NumParameters() int
NumParameters returns the number of parameters in the distribution.
func (AlphaStable) Rand ¶ added in v0.8.0
func (a AlphaStable) Rand() float64
Rand returns a random sample drawn from the distribution.
func (AlphaStable) Skewness ¶ added in v0.8.0
func (a AlphaStable) Skewness() float64
Skewness returns the skewness of the distribution. Skewness returns NaN when Alpha != 2.
func (AlphaStable) StdDev ¶ added in v0.8.0
func (a AlphaStable) StdDev() float64
StdDev returns the standard deviation of the probability distribution.
func (AlphaStable) Variance ¶ added in v0.8.0
func (a AlphaStable) Variance() float64
Variance returns the variance of the probability distribution. Variance returns +Inf when Alpha != 2.
type Bernoulli ¶
Bernoulli represents a random variable whose value is 1 with probability p and value of zero with probability 1-P. The value of P must be between 0 and 1. More information at https://en.wikipedia.org/wiki/Bernoulli_distribution.
func (Bernoulli) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (Bernoulli) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Bernoulli) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (Bernoulli) Quantile ¶
Quantile returns the minimum value of x from amongst all those values whose CDF value exceeds or equals p.
type Beta ¶
type Beta 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 }
Beta implements the Beta distribution, a two-parameter continuous distribution with support between 0 and 1.
The beta distribution has density function
x^(α-1) * (1-x)^(β-1) * Γ(α+β) / (Γ(α)*Γ(β))
For more information, see https://en.wikipedia.org/wiki/Beta_distribution
func (Beta) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (Beta) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Beta) Mode ¶
Mode returns the mode of the distribution.
Mode returns NaN if both parameters are less than or equal to 1 as a special case, 0 if only Alpha <= 1 and 1 if only Beta <= 1.
func (Beta) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
type Bhattacharyya ¶
type Bhattacharyya struct{}
Bhattacharyya is a type for computing the Bhattacharyya distance between probability distributions.
The Bhattacharyya distance is defined as
D_B = -ln(BC(l,r)) BC = \int_-∞^∞ (p(x)q(x))^(1/2) dx
Where BC is known as the Bhattacharyya coefficient. The Bhattacharyya distance is related to the Hellinger distance by
H(l,r) = sqrt(1-BC(l,r))
For more information, see
https://en.wikipedia.org/wiki/Bhattacharyya_distance
func (Bhattacharyya) DistBeta ¶
func (Bhattacharyya) DistBeta(l, r Beta) float64
DistBeta returns the Bhattacharyya distance between Beta distributions l and r. For Beta distributions, the Bhattacharyya distance is given by
-ln(B((α_l + α_r)/2, (β_l + β_r)/2) / (B(α_l,β_l), B(α_r,β_r)))
Where B is the Beta function.
func (Bhattacharyya) DistNormal ¶
func (Bhattacharyya) DistNormal(l, r Normal) float64
DistNormal returns the Bhattacharyya distance Normal distributions l and r. For Normal distributions, the Bhattacharyya distance is given by
s = (σ_l^2 + σ_r^2)/2 BC = 1/8 (μ_l-μ_r)^2/s + 1/2 ln(s/(σ_l*σ_r))
type Binomial ¶
type Binomial struct { // N is the total number of Bernoulli trials. N must be greater than 0. N float64 // P is the probability of success in any given trial. P must be in [0, 1]. P float64 Src rand.Source }
Binomial implements the binomial distribution, a discrete probability distribution that expresses the probability of a given number of successful Bernoulli trials out of a total of n, each with success probability p. The binomial distribution has the density function:
f(k) = (n choose k) p^k (1-p)^(n-k)
For more information, see https://en.wikipedia.org/wiki/Binomial_distribution.
func (Binomial) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (Binomial) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Binomial) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
type Categorical ¶
type Categorical struct {
// contains filtered or unexported fields
}
Categorical is an extension of the Bernoulli distribution where x takes values {0, 1, ..., len(w)-1} where w is the weight vector. Categorical must be initialized with NewCategorical.
func NewCategorical ¶
func NewCategorical(w []float64, src rand.Source) Categorical
NewCategorical constructs a new categorical distribution where the probability that x equals i is proportional to w[i]. All of the weights must be nonnegative, and at least one of the weights must be positive.
func (Categorical) CDF ¶
func (c Categorical) CDF(x float64) float64
CDF computes the value of the cumulative density function at x.
func (Categorical) Entropy ¶
func (c Categorical) Entropy() float64
Entropy returns the entropy of the distribution.
func (Categorical) Len ¶
func (c Categorical) Len() int
Len returns the number of values x could possibly take (the length of the initial supplied weight vector).
func (Categorical) LogProb ¶
func (c Categorical) LogProb(x float64) float64
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Categorical) Mean ¶
func (c Categorical) Mean() float64
Mean returns the mean of the probability distribution.
func (Categorical) Prob ¶
func (c Categorical) Prob(x float64) float64
Prob computes the value of the probability density function at x.
func (Categorical) Rand ¶
func (c Categorical) Rand() float64
Rand returns a random draw from the categorical distribution.
func (Categorical) Reweight ¶
func (c Categorical) Reweight(idx int, w float64)
Reweight sets the weight of item idx to w. The input weight must be non-negative, and after reweighting at least one of the weights must be positive.
func (Categorical) ReweightAll ¶
func (c Categorical) ReweightAll(w []float64)
ReweightAll resets the weights of the distribution. ReweightAll panics if len(w) != c.Len. All of the weights must be nonnegative, and at least one of the weights must be positive.
type Chi ¶ added in v0.11.0
type Chi struct { // K is the shape parameter, corresponding to the degrees of freedom. Must // be greater than 0. K float64 Src rand.Source }
Chi implements the χ distribution, a one parameter distribution with support on the positive numbers.
The density function is given by
1/(2^{k/2-1} * Γ(k/2)) * x^{k - 1} * e^{-x^2/2}
For more information, see https://en.wikipedia.org/wiki/Chi_distribution.
func (Chi) ExKurtosis ¶ added in v0.11.0
ExKurtosis returns the excess kurtosis of the distribution.
func (Chi) LogProb ¶ added in v0.11.0
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Chi) Mode ¶ added in v0.11.0
Mode returns the mode of the distribution.
Mode returns NaN if K is less than one.
func (Chi) NumParameters ¶ added in v0.11.0
NumParameters returns the number of parameters in the distribution.
func (Chi) Prob ¶ added in v0.11.0
Prob computes the value of the probability density function at x.
func (Chi) Quantile ¶ added in v0.11.0
Quantile returns the inverse of the cumulative distribution function.
func (Chi) StdDev ¶ added in v0.11.0
StdDev returns the standard deviation of the probability distribution.
type ChiSquared ¶
type ChiSquared struct { // K is the shape parameter, corresponding to the degrees of freedom. Must // be greater than 0. K float64 Src rand.Source }
ChiSquared implements the χ² distribution, a one parameter distribution with support on the positive numbers.
The density function is given by
1/(2^{k/2} * Γ(k/2)) * x^{k/2 - 1} * e^{-x/2}
It is a special case of the Gamma distribution, Γ(k/2, 1/2).
For more information, see https://en.wikipedia.org/wiki/Chi-squared_distribution.
func (ChiSquared) CDF ¶
func (c ChiSquared) CDF(x float64) float64
CDF computes the value of the cumulative density function at x.
func (ChiSquared) ExKurtosis ¶
func (c ChiSquared) ExKurtosis() float64
ExKurtosis returns the excess kurtosis of the distribution.
func (ChiSquared) LogProb ¶
func (c ChiSquared) LogProb(x float64) float64
LogProb computes the natural logarithm of the value of the probability density function at x.
func (ChiSquared) Mean ¶
func (c ChiSquared) Mean() float64
Mean returns the mean of the probability distribution.
func (ChiSquared) Mode ¶
func (c ChiSquared) Mode() float64
Mode returns the mode of the distribution.
func (ChiSquared) NumParameters ¶
func (c ChiSquared) NumParameters() int
NumParameters returns the number of parameters in the distribution.
func (ChiSquared) Prob ¶
func (c ChiSquared) Prob(x float64) float64
Prob computes the value of the probability density function at x.
func (ChiSquared) Quantile ¶
func (c ChiSquared) Quantile(p float64) float64
Quantile returns the inverse of the cumulative distribution function.
func (ChiSquared) Rand ¶
func (c ChiSquared) Rand() float64
Rand returns a random sample drawn from the distribution.
func (ChiSquared) StdDev ¶
func (c ChiSquared) StdDev() float64
StdDev returns the standard deviation of the probability distribution.
func (ChiSquared) Survival ¶
func (c ChiSquared) Survival(x float64) float64
Survival returns the survival function (complementary CDF) at x.
func (ChiSquared) Variance ¶
func (c ChiSquared) Variance() float64
Variance returns the variance of the probability distribution.
type Exponential ¶
Exponential represents the exponential distribution (https://en.wikipedia.org/wiki/Exponential_distribution).
func (Exponential) CDF ¶
func (e Exponential) CDF(x float64) float64
CDF computes the value of the cumulative density function at x.
func (*Exponential) ConjugateUpdate ¶
func (e *Exponential) ConjugateUpdate(suffStat []float64, nSamples float64, priorStrength []float64)
ConjugateUpdate updates the parameters of the distribution from the sufficient statistics of a set of samples. The sufficient statistics, suffStat, have been observed with nSamples observations. The prior values of the distribution are those currently in the distribution, and have been observed with priorStrength samples.
For the exponential distribution, the sufficient statistic is the inverse of the mean of the samples. The prior is having seen priorStrength[0] samples with inverse mean Exponential.Rate As a result of this function, Exponential.Rate is updated based on the weighted samples, and priorStrength is modified to include the new number of samples observed.
This function panics if len(suffStat) != e.NumSuffStat() or len(priorStrength) != e.NumSuffStat().
func (Exponential) Entropy ¶
func (e Exponential) Entropy() float64
Entropy returns the entropy of the distribution.
func (Exponential) ExKurtosis ¶
func (Exponential) ExKurtosis() float64
ExKurtosis returns the excess kurtosis of the distribution.
func (*Exponential) Fit ¶
func (e *Exponential) Fit(samples, weights []float64)
Fit sets the parameters of the probability distribution from the data samples x with relative weights w. If weights is nil, then all the weights are 1. If weights is not nil, then the len(weights) must equal len(samples).
func (Exponential) LogProb ¶
func (e Exponential) LogProb(x float64) float64
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Exponential) Mean ¶
func (e Exponential) Mean() float64
Mean returns the mean of the probability distribution.
func (Exponential) Median ¶
func (e Exponential) Median() float64
Median returns the median of the probability distribution.
func (Exponential) Mode ¶
func (Exponential) Mode() float64
Mode returns the mode of the probability distribution.
func (Exponential) NumParameters ¶
func (Exponential) NumParameters() int
NumParameters returns the number of parameters in the distribution.
func (Exponential) NumSuffStat ¶
func (Exponential) NumSuffStat() int
NumSuffStat returns the number of sufficient statistics for the distribution.
func (Exponential) Prob ¶
func (e Exponential) Prob(x float64) float64
Prob computes the value of the probability density function at x.
func (Exponential) Quantile ¶
func (e Exponential) Quantile(p float64) float64
Quantile returns the inverse of the cumulative probability distribution.
func (Exponential) Rand ¶
func (e Exponential) Rand() float64
Rand returns a random sample drawn from the distribution.
func (Exponential) Score ¶
func (e Exponential) Score(deriv []float64, x float64) []float64
Score returns the score function with respect to the parameters of the distribution at the input location x. The score function is the derivative of the log-likelihood at x with respect to the parameters
(∂/∂θ) log(p(x;θ))
If deriv is non-nil, len(deriv) must equal the number of parameters otherwise Score will panic, and the derivative is stored in-place into deriv. If deriv is nil a new slice will be allocated and returned.
The order is [∂LogProb / ∂Rate].
For more information, see https://en.wikipedia.org/wiki/Score_%28statistics%29.
Special cases:
Score(0) = [NaN]
func (Exponential) ScoreInput ¶
func (e Exponential) ScoreInput(x float64) float64
ScoreInput returns the score function with respect to the input of the distribution at the input location specified by x. The score function is the derivative of the log-likelihood
(d/dx) log(p(x)) .
Special cases:
ScoreInput(0) = NaN
func (Exponential) Skewness ¶
func (Exponential) Skewness() float64
Skewness returns the skewness of the distribution.
func (Exponential) StdDev ¶
func (e Exponential) StdDev() float64
StdDev returns the standard deviation of the probability distribution.
func (Exponential) SuffStat ¶
func (Exponential) SuffStat(suffStat, samples, weights []float64) (nSamples float64)
SuffStat computes the sufficient statistics of set of samples to update the distribution. The sufficient statistics are stored in place, and the effective number of samples are returned.
The exponential distribution has one sufficient statistic, the average rate of the samples.
If weights is nil, the weights are assumed to be 1, otherwise panics if len(samples) != len(weights). Panics if len(suffStat) != NumSuffStat().
func (Exponential) Survival ¶
func (e Exponential) Survival(x float64) float64
Survival returns the survival function (complementary CDF) at x.
func (Exponential) Variance ¶
func (e Exponential) Variance() float64
Variance returns the variance of the probability distribution.
type F ¶
type F struct { D1 float64 // Degrees of freedom for the numerator D2 float64 // Degrees of freedom for the denominator Src rand.Source }
F implements the F-distribution, a two-parameter continuous distribution with support over the positive real numbers.
The F-distribution has density function
sqrt(((d1*x)^d1) * d2^d2 / ((d1*x+d2)^(d1+d2))) / (x * B(d1/2,d2/2))
where B is the beta function.
For more information, see https://en.wikipedia.org/wiki/F-distribution
func (F) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
ExKurtosis returns NaN if the D2 parameter is less or equal to 8.
func (F) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (F) Mean ¶
Mean returns the mean of the probability distribution.
Mean returns NaN if the D2 parameter is less than or equal to 2.
func (F) Mode ¶
Mode returns the mode of the distribution.
Mode returns NaN if the D1 parameter is less than or equal to 2.
func (F) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (F) Skewness ¶
Skewness returns the skewness of the distribution.
Skewness returns NaN if the D2 parameter is less than or equal to 6.
func (F) StdDev ¶
StdDev returns the standard deviation of the probability distribution.
StdDev returns NaN if the D2 parameter is less than or equal to 4.
type Gamma ¶
type Gamma struct { // Alpha is the shape parameter of the distribution. Alpha must be greater // than 0. If Alpha == 1, this is equivalent to an exponential distribution. Alpha float64 // Beta is the rate parameter of the distribution. Beta must be greater than 0. // If Beta == 2, this is equivalent to a Chi-Squared distribution. Beta float64 Src rand.Source }
Gamma implements the Gamma distribution, a two-parameter continuous distribution with support over the positive real numbers.
The gamma distribution has density function
β^α / Γ(α) x^(α-1)e^(-βx)
For more information, see https://en.wikipedia.org/wiki/Gamma_distribution
func (Gamma) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (Gamma) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Gamma) Mode ¶
Mode returns the mode of the gamma distribution.
The mode is 0 in the special case where the Alpha (shape) parameter is less than 1.
func (Gamma) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (Gamma) Rand ¶
Rand returns a random sample drawn from the distribution.
Rand panics if either alpha or beta is <= 0.
type GumbelRight ¶
GumbelRight implements the right-skewed Gumbel distribution, a two-parameter continuous distribution with support over the real numbers. The right-skewed Gumbel distribution is also sometimes known as the Extreme Value distribution.
The right-skewed Gumbel distribution has density function
1/beta * exp(-(z + exp(-z))) z = (x - mu)/beta
Beta must be greater than 0.
For more information, see https://en.wikipedia.org/wiki/Gumbel_distribution.
func (GumbelRight) CDF ¶
func (g GumbelRight) CDF(x float64) float64
CDF computes the value of the cumulative density function at x.
func (GumbelRight) Entropy ¶
func (g GumbelRight) Entropy() float64
Entropy returns the differential entropy of the distribution.
func (GumbelRight) ExKurtosis ¶
func (g GumbelRight) ExKurtosis() float64
ExKurtosis returns the excess kurtosis of the distribution.
func (GumbelRight) LogProb ¶
func (g GumbelRight) LogProb(x float64) float64
LogProb computes the natural logarithm of the value of the probability density function at x.
func (GumbelRight) Mean ¶
func (g GumbelRight) Mean() float64
Mean returns the mean of the probability distribution.
func (GumbelRight) Median ¶
func (g GumbelRight) Median() float64
Median returns the median of the Gumbel distribution.
func (GumbelRight) Mode ¶
func (g GumbelRight) Mode() float64
Mode returns the mode of the normal distribution.
func (GumbelRight) NumParameters ¶
func (GumbelRight) NumParameters() int
NumParameters returns the number of parameters in the distribution.
func (GumbelRight) Prob ¶
func (g GumbelRight) Prob(x float64) float64
Prob computes the value of the probability density function at x.
func (GumbelRight) Quantile ¶
func (g GumbelRight) Quantile(p float64) float64
Quantile returns the inverse of the cumulative probability distribution.
func (GumbelRight) Rand ¶
func (g GumbelRight) Rand() float64
Rand returns a random sample drawn from the distribution.
func (GumbelRight) Skewness ¶
func (GumbelRight) Skewness() float64
Skewness returns the skewness of the distribution.
func (GumbelRight) StdDev ¶
func (g GumbelRight) StdDev() float64
StdDev returns the standard deviation of the probability distribution.
func (GumbelRight) Survival ¶
func (g GumbelRight) Survival(x float64) float64
Survival returns the survival function (complementary CDF) at x.
func (GumbelRight) Variance ¶
func (g GumbelRight) Variance() float64
Variance returns the variance of the probability distribution.
type Hellinger ¶
type Hellinger struct{}
Hellinger is a type for computing the Hellinger distance between probability distributions.
The Hellinger distance is defined as
H^2(l,r) = 1/2 * int_x (\sqrt(l(x)) - \sqrt(r(x)))^2 dx
and is bounded between 0 and 1. Note the above formula defines the squared Hellinger distance, while this returns the Hellinger distance itself. The Hellinger distance is related to the Bhattacharyya distance by
H^2 = 1 - exp(-D_B)
For more information, see
https://en.wikipedia.org/wiki/Hellinger_distance
func (Hellinger) DistBeta ¶
DistBeta computes the Hellinger distance between Beta distributions l and r. See the documentation of Bhattacharyya.DistBeta for the distance formula.
func (Hellinger) DistNormal ¶
DistNormal computes the Hellinger distance between Normal distributions l and r. See the documentation of Bhattacharyya.DistNormal for the distance formula.
type InverseGamma ¶
type InverseGamma struct { // Alpha is the shape parameter of the distribution. Alpha must be greater than 0. Alpha float64 // Beta is the scale parameter of the distribution. Beta must be greater than 0. Beta float64 Src rand.Source }
InverseGamma implements the inverse gamma distribution, a two-parameter continuous distribution with support over the positive real numbers. The inverse gamma distribution is the same as the distribution of the reciprocal of a gamma distributed random variable.
The inverse gamma distribution has density function
β^α / Γ(α) x^(-α-1)e^(-β/x)
For more information, see https://en.wikipedia.org/wiki/Inverse-gamma_distribution
func (InverseGamma) CDF ¶
func (g InverseGamma) CDF(x float64) float64
CDF computes the value of the cumulative distribution function at x.
func (InverseGamma) ExKurtosis ¶
func (g InverseGamma) ExKurtosis() float64
ExKurtosis returns the excess kurtosis of the distribution.
func (InverseGamma) LogProb ¶
func (g InverseGamma) LogProb(x float64) float64
LogProb computes the natural logarithm of the value of the probability density function at x.
func (InverseGamma) Mean ¶
func (g InverseGamma) Mean() float64
Mean returns the mean of the probability distribution.
func (InverseGamma) Mode ¶
func (g InverseGamma) Mode() float64
Mode returns the mode of the distribution.
func (InverseGamma) NumParameters ¶
func (InverseGamma) NumParameters() int
NumParameters returns the number of parameters in the distribution.
func (InverseGamma) Prob ¶
func (g InverseGamma) Prob(x float64) float64
Prob computes the value of the probability density function at x.
func (InverseGamma) Quantile ¶
func (g InverseGamma) Quantile(p float64) float64
Quantile returns the inverse of the cumulative distribution function.
func (InverseGamma) Rand ¶
func (g InverseGamma) Rand() float64
Rand returns a random sample drawn from the distribution.
Rand panics if either alpha or beta is <= 0.
func (InverseGamma) StdDev ¶
func (g InverseGamma) StdDev() float64
StdDev returns the standard deviation of the probability distribution.
func (InverseGamma) Survival ¶
func (g InverseGamma) Survival(x float64) float64
Survival returns the survival function (complementary CDF) at x.
func (InverseGamma) Variance ¶
func (g InverseGamma) Variance() float64
Variance returns the variance of the probability distribution.
type KullbackLeibler ¶
type KullbackLeibler struct{}
KullbackLeibler is a type for computing the Kullback-Leibler divergence from l to r.
The Kullback-Leibler divergence is defined as
D_KL(l || r ) = \int_x p(x) log(p(x)/q(x)) dx
Note that the Kullback-Leibler divergence is not symmetric with respect to the order of the input arguments.
func (KullbackLeibler) DistBeta ¶
func (KullbackLeibler) DistBeta(l, r Beta) float64
DistBeta returns the Kullback-Leibler divergence between Beta distributions l and r.
For two Beta distributions, the KL divergence is computed as
D_KL(l || r) = log Γ(α_l+β_l) - log Γ(α_l) - log Γ(β_l) - log Γ(α_r+β_r) + log Γ(α_r) + log Γ(β_r) + (α_l-α_r)(ψ(α_l)-ψ(α_l+β_l)) + (β_l-β_r)(ψ(β_l)-ψ(α_l+β_l))
Where Γ is the gamma function and ψ is the digamma function.
func (KullbackLeibler) DistNormal ¶
func (KullbackLeibler) DistNormal(l, r Normal) float64
DistNormal returns the Kullback-Leibler divergence between Normal distributions l and r.
For two Normal distributions, the KL divergence is computed as
D_KL(l || r) = log(σ_r / σ_l) + (σ_l^2 + (μ_l-μ_r)^2)/(2 * σ_r^2) - 0.5
type Laplace ¶
type Laplace struct { Mu float64 // Mean of the Laplace distribution Scale float64 // Scale of the Laplace distribution Src rand.Source }
Laplace represents the Laplace distribution (https://en.wikipedia.org/wiki/Laplace_distribution).
func (Laplace) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (*Laplace) Fit ¶
Fit sets the parameters of the probability distribution from the data samples x with relative weights w. If weights is nil, then all the weights are 1. If weights is not nil, then the len(weights) must equal len(samples).
Note: Laplace distribution has no FitPrior because it has no sufficient statistics.
func (Laplace) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Laplace) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (Laplace) Score ¶
Score returns the score function with respect to the parameters of the distribution at the input location x. The score function is the derivative of the log-likelihood at x with respect to the parameters
(∂/∂θ) log(p(x;θ))
If deriv is non-nil, len(deriv) must equal the number of parameters otherwise Score will panic, and the derivative is stored in-place into deriv. If deriv is nil a new slice will be allocated and returned.
The order is [∂LogProb / ∂Mu, ∂LogProb / ∂Scale].
For more information, see https://en.wikipedia.org/wiki/Score_%28statistics%29.
Special cases:
Score(l.Mu) = [NaN, -1/l.Scale]
func (Laplace) ScoreInput ¶
ScoreInput returns the score function with respect to the input of the distribution at the input location specified by x. The score function is the derivative of the log-likelihood
(d/dx) log(p(x)) .
Special cases:
ScoreInput(l.Mu) = NaN
type LogNormal ¶
LogNormal represents a random variable whose log is normally distributed. The probability density function is given by
1/(x σ √2π) exp(-(ln(x)-μ)^2)/(2σ^2))
func (LogNormal) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (LogNormal) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (LogNormal) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (LogNormal) Quantile ¶
Quantile returns the inverse of the cumulative probability distribution.
type LogProber ¶
type LogProber interface { // LogProb returns the natural logarithm of the // value of the probability density or probability // mass function at x. LogProb(x float64) float64 }
LogProber wraps the LogProb method.
type Logistic ¶ added in v0.11.0
type Logistic struct { Mu float64 // Mean value S float64 // Scale parameter proportional to standard deviation }
Logistic implements the Logistic distribution, a two-parameter distribution with support on the real axis. Its cumulative distribution function is the logistic function.
General form of probability density function for Logistic distribution is
E(x) / (s * (1 + E(x))^2) where E(x) = exp(-(x-μ)/s)
For more information, see https://en.wikipedia.org/wiki/Logistic_distribution.
func (Logistic) CDF ¶ added in v0.11.0
CDF computes the value of the cumulative density function at x.
func (Logistic) ExKurtosis ¶ added in v0.11.0
ExKurtosis returns the excess kurtosis of the distribution.
func (Logistic) LogProb ¶ added in v0.11.0
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Logistic) Median ¶ added in v0.11.0
Median returns the median of the distribution.
It is same as Mean for Logistic distribution.
func (Logistic) Mode ¶ added in v0.11.0
Mode returns the mode of the distribution.
It is same as Mean for Logistic distribution.
func (Logistic) NumParameters ¶ added in v0.11.0
NumParameters returns the number of parameters in the distribution.
Always returns 2.
func (Logistic) Prob ¶ added in v0.11.0
Prob computes the value of the probability density function at x.
func (Logistic) Quantile ¶ added in v0.11.0
Quantile returns the inverse of the cumulative distribution function.
func (Logistic) Skewness ¶ added in v0.11.0
Skewness returns the skewness of the distribution.
Always 0 for Logistic distribution.
func (Logistic) StdDev ¶ added in v0.11.0
StdDev returns the standard deviation of the probability distribution.
type Normal ¶
type Normal struct { Mu float64 // Mean of the normal distribution Sigma float64 // Standard deviation of the normal distribution Src rand.Source }
Normal represents a normal (Gaussian) distribution (https://en.wikipedia.org/wiki/Normal_distribution).
Example ¶
package main import ( "fmt" "gonum.org/v1/gonum/stat" "gonum.org/v1/gonum/stat/distuv" ) func main() { // Create a normal distribution dist := distuv.Normal{ Mu: 2, Sigma: 5, } data := make([]float64, 1e5) // Draw some random values from the standard normal distribution for i := range data { data[i] = dist.Rand() } mean, std := stat.MeanStdDev(data, nil) meanErr := stat.StdErr(std, float64(len(data))) fmt.Printf("mean= %1.1f ± %0.1v\n", mean, meanErr) }
Output: mean= 2.0 ± 0.02
func (*Normal) ConjugateUpdate ¶
ConjugateUpdate updates the parameters of the distribution from the sufficient statistics of a set of samples. The sufficient statistics, suffStat, have been observed with nSamples observations. The prior values of the distribution are those currently in the distribution, and have been observed with priorStrength samples.
For the normal distribution, the sufficient statistics are the mean and uncorrected standard deviation of the samples. The prior is having seen strength[0] samples with mean Normal.Mu and strength[1] samples with standard deviation Normal.Sigma. As a result of this function, Normal.Mu and Normal.Sigma are updated based on the weighted samples, and strength is modified to include the new number of samples observed.
This function panics if len(suffStat) != n.NumSuffStat() or len(priorStrength) != n.NumSuffStat().
func (Normal) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (*Normal) Fit ¶
Fit sets the parameters of the probability distribution from the data samples x with relative weights w. If weights is nil, then all the weights are 1. If weights is not nil, then the len(weights) must equal len(samples).
func (Normal) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Normal) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (Normal) NumSuffStat ¶
NumSuffStat returns the number of sufficient statistics for the distribution.
func (Normal) Score ¶
Score returns the score function with respect to the parameters of the distribution at the input location x. The score function is the derivative of the log-likelihood at x with respect to the parameters
(∂/∂θ) log(p(x;θ))
If deriv is non-nil, len(deriv) must equal the number of parameters otherwise Score will panic, and the derivative is stored in-place into deriv. If deriv is nil a new slice will be allocated and returned.
The order is [∂LogProb / ∂Mu, ∂LogProb / ∂Sigma].
For more information, see https://en.wikipedia.org/wiki/Score_%28statistics%29.
func (Normal) ScoreInput ¶
ScoreInput returns the score function with respect to the input of the distribution at the input location specified by x. The score function is the derivative of the log-likelihood
(d/dx) log(p(x)) .
func (Normal) SuffStat ¶
SuffStat computes the sufficient statistics of a set of samples to update the distribution. The sufficient statistics are stored in place, and the effective number of samples are returned.
The normal distribution has two sufficient statistics, the mean of the samples and the standard deviation of the samples.
If weights is nil, the weights are assumed to be 1, otherwise panics if len(samples) != len(weights). Panics if len(suffStat) != NumSuffStat().
type Pareto ¶
type Pareto struct { // Xm is the scale parameter. // Xm must be greater than 0. Xm float64 // Alpha is the shape parameter. // Alpha must be greater than 0. Alpha float64 Src rand.Source }
Pareto implements the Pareto (Type I) distribution, a one parameter distribution with support above the scale parameter.
The density function is given by
(α x_m^{α})/(x^{α+1}) for x >= x_m.
For more information, see https://en.wikipedia.org/wiki/Pareto_distribution.
func (Pareto) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (Pareto) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Pareto) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (Pareto) Quantile ¶ added in v0.8.0
Quantile returns the inverse of the cumulative probability distribution.
type Poisson ¶
type Poisson struct { // Lambda is the average number of events in an interval. // Lambda must be greater than 0. Lambda float64 Src rand.Source }
Poisson implements the Poisson distribution, a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval. The poisson distribution has density function:
f(k) = λ^k / k! e^(-λ)
For more information, see https://en.wikipedia.org/wiki/Poisson_distribution.
func (Poisson) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (Poisson) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Poisson) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
type Quantiler ¶
type Quantiler interface { // Quantile returns the minimum value of x from amongst // all those values whose CDF value exceeds or equals p. Quantile(p float64) float64 }
Quantiler wraps the Quantile method.
type RandLogProber ¶
RandLogProber is the interface that groups the Rander and LogProber methods.
type Rander ¶
type Rander interface { // Rand returns a random sample drawn from the distribution. Rand() float64 }
Rander wraps the Rand method.
type StudentsT ¶
type StudentsT struct { // Mu is the location parameter of the distribution, and the mean of the // distribution Mu float64 // Sigma is the scale parameter of the distribution. It is related to the // standard deviation by std = Sigma * sqrt(Nu/(Nu-2)) Sigma float64 // Nu is the shape parameter of the distribution, representing the number of // degrees of the distribution, and one less than the number of observations // from a Normal distribution. Nu float64 Src rand.Source }
StudentsT implements the three-parameter Student's T distribution, a distribution over the real numbers.
The Student's T distribution has density function
Γ((ν+1)/2) / (sqrt(νπ) Γ(ν/2) σ) (1 + 1/ν * ((x-μ)/σ)^2)^(-(ν+1)/2)
The Student's T distribution approaches the normal distribution as ν → ∞.
For more information, see https://en.wikipedia.org/wiki/Student%27s_t-distribution, specifically https://en.wikipedia.org/wiki/Student%27s_t-distribution#Non-standardized_Student.27s_t-distribution .
The standard Student's T distribution is with Mu = 0, and Sigma = 1.
func (StudentsT) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (StudentsT) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (StudentsT) StdDev ¶
StdDev returns the standard deviation of the probability distribution.
The standard deviation is undefined for ν <= 1, and this returns math.NaN().
type Triangle ¶
type Triangle struct {
// contains filtered or unexported fields
}
Triangle represents a triangle distribution (https://en.wikipedia.org/wiki/Triangular_distribution).
func NewTriangle ¶
NewTriangle constructs a new triangle distribution with lower limit a, upper limit b, and mode c. Constraints are a < b and a ≤ c ≤ b. This distribution is uncommon in nature, but may be useful for simulation.
func (Triangle) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (Triangle) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Triangle) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (Triangle) Score ¶ added in v0.8.0
Score returns the score function with respect to the parameters of the distribution at the input location x. The score function is the derivative of the log-likelihood at x with respect to the parameters
(∂/∂θ) log(p(x;θ))
If deriv is non-nil, len(deriv) must equal the number of parameters otherwise Score will panic, and the derivative is stored in-place into deriv. If deriv is nil a new slice will be allocated and returned.
The order is [∂LogProb / ∂Mu, ∂LogProb / ∂Sigma].
For more information, see https://en.wikipedia.org/wiki/Score_%28statistics%29.
func (Triangle) ScoreInput ¶ added in v0.8.0
ScoreInput returns the score function with respect to the input of the distribution at the input location specified by x. The score function is the derivative of the log-likelihood
(d/dx) log(p(x)) .
Special cases (c is the mode of the distribution):
ScoreInput(c) = NaN ScoreInput(x) = NaN for x not in (a, b)
type Uniform ¶
Uniform represents a continuous uniform distribution (https://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29).
func (Uniform) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (Uniform) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x.
func (Uniform) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (Uniform) Score ¶ added in v0.8.0
Score returns the score function with respect to the parameters of the distribution at the input location x. The score function is the derivative of the log-likelihood at x with respect to the parameters
(∂/∂θ) log(p(x;θ))
If deriv is non-nil, len(deriv) must equal the number of parameters otherwise Score will panic, and the derivative is stored in-place into deriv. If deriv is nil a new slice will be allocated and returned.
The order is [∂LogProb / ∂Mu, ∂LogProb / ∂Sigma].
For more information, see https://en.wikipedia.org/wiki/Score_%28statistics%29.
func (Uniform) ScoreInput ¶ added in v0.8.0
ScoreInput returns the score function with respect to the input of the distribution at the input location specified by x. The score function is the derivative of the log-likelihood
(d/dx) log(p(x)) .
type Weibull ¶
type Weibull struct { // Shape parameter of the distribution. A value of 1 represents // the exponential distribution. A value of 2 represents the // Rayleigh distribution. Valid range is (0,+∞). K float64 // Scale parameter of the distribution. Valid range is (0,+∞). Lambda float64 // Source of random numbers Src rand.Source }
Weibull distribution. Valid range for x is [0,+∞).
func (Weibull) ExKurtosis ¶
ExKurtosis returns the excess kurtosis of the distribution.
func (Weibull) LogProb ¶
LogProb computes the natural logarithm of the value of the probability density function at x. -Inf is returned if x is less than zero.
Special cases occur when x == 0, and the result depends on the shape parameter as follows:
If 0 < K < 1, LogProb returns +Inf. If K == 1, LogProb returns 0. If K > 1, LogProb returns -Inf.
func (Weibull) LogSurvival ¶
LogSurvival returns the log of the survival function (complementary CDF) at x.
func (Weibull) Mode ¶
Mode returns the mode of the normal distribution.
The mode is NaN in the special case where the K (shape) parameter is less than 1.
func (Weibull) NumParameters ¶
NumParameters returns the number of parameters in the distribution.
func (Weibull) Score ¶
Score returns the score function with respect to the parameters of the distribution at the input location x. The score function is the derivative of the log-likelihood at x with respect to the parameters
(∂/∂θ) log(p(x;θ))
If deriv is non-nil, len(deriv) must equal the number of parameters otherwise Score will panic, and the derivative is stored in-place into deriv. If deriv is nil a new slice will be allocated and returned.
The order is [∂LogProb / ∂K, ∂LogProb / ∂λ].
For more information, see https://en.wikipedia.org/wiki/Score_%28statistics%29.
Special cases:
Score(x) = [NaN, NaN] for x <= 0
func (Weibull) ScoreInput ¶
ScoreInput returns the score function with respect to the input of the distribution at the input location specified by x. The score function is the derivative of the log-likelihood
(d/dx) log(p(x)) .
Special cases:
ScoreInput(x) = NaN for x <= 0
Source Files ¶
- alphastable.go
- bernoulli.go
- beta.go
- binomial.go
- categorical.go
- chi.go
- chisquared.go
- constants.go
- doc.go
- exponential.go
- f.go
- gamma.go
- general.go
- gumbel.go
- interfaces.go
- inversegamma.go
- laplace.go
- logistic.go
- lognormal.go
- norm.go
- pareto.go
- poisson.go
- statdist.go
- studentst.go
- triangle.go
- uniform.go
- weibull.go