gonum: gonum.org/v1/gonum/stat/distuv

## package distuv

import "gonum.org/v1/gonum/stat/distuv"

Package distuv provides univariate random distribution types.

### 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.

### type Bernoulli¶Uses

type Bernoulli struct {
P   float64
Src rand.Source
}

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) CDF¶Uses

func (b Bernoulli) CDF(x float64) float64

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

#### func (Bernoulli) Entropy¶Uses

func (b Bernoulli) Entropy() float64

Entropy returns the entropy of the distribution.

#### func (Bernoulli) ExKurtosis¶Uses

func (b Bernoulli) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (Bernoulli) LogProb¶Uses

func (b Bernoulli) LogProb(x float64) float64

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

#### func (Bernoulli) Mean¶Uses

func (b Bernoulli) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Bernoulli) Median¶Uses

func (b Bernoulli) Median() float64

Median returns the median of the probability distribution.

#### func (Bernoulli) NumParameters¶Uses

func (Bernoulli) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Bernoulli) Prob¶Uses

func (b Bernoulli) Prob(x float64) float64

Prob computes the value of the probability distribution at x.

#### func (Bernoulli) Quantile¶Uses

func (b Bernoulli) Quantile(p float64) float64

Quantile returns the inverse of the cumulative probability distribution.

#### func (Bernoulli) Rand¶Uses

func (b Bernoulli) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Bernoulli) Skewness¶Uses

func (b Bernoulli) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (Bernoulli) StdDev¶Uses

func (b Bernoulli) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Bernoulli) Survival¶Uses

func (b Bernoulli) Survival(x float64) float64

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

#### func (Bernoulli) Variance¶Uses

func (b Bernoulli) Variance() float64

Variance returns the variance of the probability distribution.

### type Beta¶Uses

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) * Γ(α+β) / (Γ(α)*Γ(β))


#### func (Beta) CDF¶Uses

func (b Beta) CDF(x float64) float64

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

#### func (Beta) Entropy¶Uses

func (b Beta) Entropy() float64

Entropy returns the differential entropy of the distribution.

#### func (Beta) ExKurtosis¶Uses

func (b Beta) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (Beta) LogProb¶Uses

func (b Beta) LogProb(x float64) float64

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

#### func (Beta) Mean¶Uses

func (b Beta) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Beta) Mode¶Uses

func (b Beta) Mode() float64

Mode returns the mode of the distribution.

Mode returns NaN if either parameter is less than or equal to 1 as a special case.

#### func (Beta) NumParameters¶Uses

func (b Beta) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Beta) Prob¶Uses

func (b Beta) Prob(x float64) float64

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

#### func (Beta) Quantile¶Uses

func (b Beta) Quantile(p float64) float64

Quantile returns the inverse of the cumulative distribution function.

#### func (Beta) Rand¶Uses

func (b Beta) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Beta) StdDev¶Uses

func (b Beta) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Beta) Survival¶Uses

func (b Beta) Survival(x float64) float64

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

#### func (Beta) Variance¶Uses

func (b Beta) Variance() float64

Variance returns the variance of the probability distribution.

### type Bhattacharyya¶Uses

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))


https://en.wikipedia.org/wiki/Bhattacharyya_distance


#### func (Bhattacharyya) DistBeta¶Uses

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¶Uses

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¶Uses

type Binomial struct {
// N is the total number of Bernoulli trials. N must be greater than 0.
N   float64
// P is the probablity 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)


#### func (Binomial) CDF¶Uses

func (b Binomial) CDF(x float64) float64

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

#### func (Binomial) ExKurtosis¶Uses

func (b Binomial) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (Binomial) LogProb¶Uses

func (b Binomial) LogProb(x float64) float64

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

#### func (Binomial) Mean¶Uses

func (b Binomial) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Binomial) NumParameters¶Uses

func (Binomial) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Binomial) Prob¶Uses

func (b Binomial) Prob(x float64) float64

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

#### func (Binomial) Rand¶Uses

func (b Binomial) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Binomial) Skewness¶Uses

func (b Binomial) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (Binomial) StdDev¶Uses

func (b Binomial) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Binomial) Survival¶Uses

func (b Binomial) Survival(x float64) float64

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

#### func (Binomial) Variance¶Uses

func (b Binomial) Variance() float64

Variance returns the variance of the probability distribution.

### type Categorical¶Uses

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¶Uses

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¶Uses

func (c Categorical) CDF(x float64) float64

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

#### func (Categorical) Entropy¶Uses

func (c Categorical) Entropy() float64

Entropy returns the entropy of the distribution.

#### func (Categorical) Len¶Uses

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¶Uses

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¶Uses

func (c Categorical) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Categorical) Prob¶Uses

func (c Categorical) Prob(x float64) float64

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

#### func (Categorical) Rand¶Uses

func (c Categorical) Rand() float64

Rand returns a random draw from the categorical distribution.

#### func (Categorical) Reweight¶Uses

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¶Uses

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 ChiSquared¶Uses

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).

#### func (ChiSquared) CDF¶Uses

func (c ChiSquared) CDF(x float64) float64

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

#### func (ChiSquared) ExKurtosis¶Uses

func (c ChiSquared) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (ChiSquared) LogProb¶Uses

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¶Uses

func (c ChiSquared) Mean() float64

Mean returns the mean of the probability distribution.

#### func (ChiSquared) Mode¶Uses

func (c ChiSquared) Mode() float64

Mode returns the mode of the distribution.

#### func (ChiSquared) NumParameters¶Uses

func (c ChiSquared) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (ChiSquared) Prob¶Uses

func (c ChiSquared) Prob(x float64) float64

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

#### func (ChiSquared) Quantile¶Uses

func (c ChiSquared) Quantile(p float64) float64

Quantile returns the inverse of the cumulative distribution function.

#### func (ChiSquared) Rand¶Uses

func (c ChiSquared) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (ChiSquared) StdDev¶Uses

func (c ChiSquared) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (ChiSquared) Survival¶Uses

func (c ChiSquared) Survival(x float64) float64

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

#### func (ChiSquared) Variance¶Uses

func (c ChiSquared) Variance() float64

Variance returns the variance of the probability distribution.

### type Exponential¶Uses

type Exponential struct {
Rate float64
Src  rand.Source
}

Exponential represents the exponential distribution (https://en.wikipedia.org/wiki/Exponential_distribution).

#### func (Exponential) CDF¶Uses

func (e Exponential) CDF(x float64) float64

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

#### func (*Exponential) ConjugateUpdate¶Uses

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 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) != 1 or len(priorStrength) != 1.

#### func (Exponential) Entropy¶Uses

func (e Exponential) Entropy() float64

Entropy returns the entropy of the distribution.

#### func (Exponential) ExKurtosis¶Uses

func (Exponential) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (*Exponential) Fit¶Uses

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¶Uses

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¶Uses

func (e Exponential) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Exponential) Median¶Uses

func (e Exponential) Median() float64

Median returns the median of the probability distribution.

#### func (Exponential) Mode¶Uses

func (Exponential) Mode() float64

Mode returns the mode of the probability distribution.

#### func (Exponential) NumParameters¶Uses

func (Exponential) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Exponential) NumSuffStat¶Uses

func (Exponential) NumSuffStat() int

NumSuffStat returns the number of sufficient statistics for the distribution.

#### func (Exponential) Prob¶Uses

func (e Exponential) Prob(x float64) float64

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

#### func (Exponential) Quantile¶Uses

func (e Exponential) Quantile(p float64) float64

Quantile returns the inverse of the cumulative probability distribution.

#### func (Exponential) Rand¶Uses

func (e Exponential) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Exponential) Score¶Uses

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].

Special cases:

Score(0) = [NaN]


#### func (Exponential) ScoreInput¶Uses

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¶Uses

func (Exponential) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (Exponential) StdDev¶Uses

func (e Exponential) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Exponential) SuffStat¶Uses

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¶Uses

func (e Exponential) Survival(x float64) float64

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

#### func (Exponential) Variance¶Uses

func (e Exponential) Variance() float64

Variance returns the variance of the probability distribution.

### type F¶Uses

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.

#### func (F) CDF¶Uses

func (f F) CDF(x float64) float64

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

#### func (F) ExKurtosis¶Uses

func (f F) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

ExKurtosis returns NaN if the D2 parameter is less or equal to 8.

#### func (F) LogProb¶Uses

func (f F) LogProb(x float64) float64

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

#### func (F) Mean¶Uses

func (f F) Mean() float64

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¶Uses

func (f F) Mode() float64

Mode returns the mode of the distribution.

Mode returns NaN if the D1 parameter is less than or equal to 2.

#### func (F) NumParameters¶Uses

func (f F) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (F) Prob¶Uses

func (f F) Prob(x float64) float64

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

#### func (F) Quantile¶Uses

func (f F) Quantile(p float64) float64

Quantile returns the inverse of the cumulative distribution function.

#### func (F) Rand¶Uses

func (f F) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (F) Skewness¶Uses

func (f F) Skewness() float64

Skewness returns the skewness of the distribution.

Skewness returns NaN if the D2 parameter is less than or equal to 6.

#### func (F) StdDev¶Uses

func (f F) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

StdDev returns NaN if the D2 parameter is less than or equal to 4.

#### func (F) Survival¶Uses

func (f F) Survival(x float64) float64

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

#### func (F) Variance¶Uses

func (f F) Variance() float64

Variance returns the variance of the probability distribution.

Variance returns NaN if the D2 parameter is less than or equal to 4.

### type Gamma¶Uses

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)


#### func (Gamma) CDF¶Uses

func (g Gamma) CDF(x float64) float64

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

#### func (Gamma) ExKurtosis¶Uses

func (g Gamma) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (Gamma) LogProb¶Uses

func (g Gamma) LogProb(x float64) float64

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

#### func (Gamma) Mean¶Uses

func (g Gamma) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Gamma) Mode¶Uses

func (g Gamma) Mode() float64

Mode returns the mode of the normal distribution.

The mode is NaN in the special case where the Alpha (shape) parameter is less than 1.

#### func (Gamma) NumParameters¶Uses

func (Gamma) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Gamma) Prob¶Uses

func (g Gamma) Prob(x float64) float64

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

#### func (Gamma) Quantile¶Uses

func (g Gamma) Quantile(p float64) float64

Quantile returns the inverse of the cumulative distribution function.

#### func (Gamma) Rand¶Uses

func (g Gamma) Rand() float64

Rand returns a random sample drawn from the distribution.

Rand panics if either alpha or beta is <= 0.

#### func (Gamma) StdDev¶Uses

func (g Gamma) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Gamma) Survival¶Uses

func (g Gamma) Survival(x float64) float64

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

#### func (Gamma) Variance¶Uses

func (g Gamma) Variance() float64

Variance returns the variance of the probability distribution.

### type GumbelRight¶Uses

type GumbelRight struct {
Mu   float64
Beta float64
Src  rand.Source
}

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.

#### func (GumbelRight) CDF¶Uses

func (g GumbelRight) CDF(x float64) float64

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

#### func (GumbelRight) Entropy¶Uses

func (g GumbelRight) Entropy() float64

Entropy returns the differential entropy of the distribution.

#### func (GumbelRight) ExKurtosis¶Uses

func (g GumbelRight) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (GumbelRight) LogProb¶Uses

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¶Uses

func (g GumbelRight) Mean() float64

Mean returns the mean of the probability distribution.

#### func (GumbelRight) Median¶Uses

func (g GumbelRight) Median() float64

Median returns the median of the normal distribution.

#### func (GumbelRight) Mode¶Uses

func (g GumbelRight) Mode() float64

Mode returns the mode of the normal distribution.

#### func (GumbelRight) NumParameters¶Uses

func (GumbelRight) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (GumbelRight) Prob¶Uses

func (g GumbelRight) Prob(x float64) float64

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

#### func (GumbelRight) Quantile¶Uses

func (g GumbelRight) Quantile(p float64) float64

Quantile returns the inverse of the cumulative probability distribution.

#### func (GumbelRight) Rand¶Uses

func (g GumbelRight) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (GumbelRight) Skewness¶Uses

func (GumbelRight) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (GumbelRight) StdDev¶Uses

func (g GumbelRight) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (GumbelRight) Survival¶Uses

func (g GumbelRight) Survival(x float64) float64

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

#### func (GumbelRight) Variance¶Uses

func (g GumbelRight) Variance() float64

Variance returns the variance of the probability distribution.

### type Hellinger¶Uses

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)


https://en.wikipedia.org/wiki/Hellinger_distance


#### func (Hellinger) DistBeta¶Uses

func (Hellinger) DistBeta(l, r Beta) float64

DistBeta computes the Hellinger distance between Beta distributions l and r. See the documentation of Bhattacharyya.DistBeta for the distance formula.

#### func (Hellinger) DistNormal¶Uses

func (Hellinger) DistNormal(l, r Normal) float64

DistNormal computes the Hellinger distance between Normal distributions l and r. See the documentation of Bhattacharyya.DistNormal for the distance formula.

### type InverseGamma¶Uses

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)


#### func (InverseGamma) CDF¶Uses

func (g InverseGamma) CDF(x float64) float64

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

#### func (InverseGamma) ExKurtosis¶Uses

func (g InverseGamma) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (InverseGamma) LogProb¶Uses

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¶Uses

func (g InverseGamma) Mean() float64

Mean returns the mean of the probability distribution.

#### func (InverseGamma) Mode¶Uses

func (g InverseGamma) Mode() float64

Mode returns the mode of the distribution.

#### func (InverseGamma) NumParameters¶Uses

func (InverseGamma) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (InverseGamma) Prob¶Uses

func (g InverseGamma) Prob(x float64) float64

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

#### func (InverseGamma) Quantile¶Uses

func (g InverseGamma) Quantile(p float64) float64

Quantile returns the inverse of the cumulative distribution function.

#### func (InverseGamma) Rand¶Uses

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¶Uses

func (g InverseGamma) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (InverseGamma) Survival¶Uses

func (g InverseGamma) Survival(x float64) float64

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

#### func (InverseGamma) Variance¶Uses

func (g InverseGamma) Variance() float64

Variance returns the variance of the probability distribution.

### type KullbackLeibler¶Uses

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¶Uses

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¶Uses

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¶Uses

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) CDF¶Uses

func (l Laplace) CDF(x float64) float64

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

#### func (Laplace) Entropy¶Uses

func (l Laplace) Entropy() float64

Entropy returns the entropy of the distribution.

#### func (Laplace) ExKurtosis¶Uses

func (l Laplace) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (*Laplace) Fit¶Uses

func (l *Laplace) 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).

Note: Laplace distribution has no FitPrior because it has no sufficient statistics.

#### func (Laplace) LogProb¶Uses

func (l Laplace) LogProb(x float64) float64

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

#### func (Laplace) MarshalParameters¶Uses

func (l Laplace) MarshalParameters(p []Parameter)

MarshalParameters implements the ParameterMarshaler interface

#### func (Laplace) Mean¶Uses

func (l Laplace) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Laplace) Median¶Uses

func (l Laplace) Median() float64

Median returns the median of the LaPlace distribution.

#### func (Laplace) Mode¶Uses

func (l Laplace) Mode() float64

Mode returns the mode of the LaPlace distribution.

#### func (Laplace) NumParameters¶Uses

func (l Laplace) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Laplace) Prob¶Uses

func (l Laplace) Prob(x float64) float64

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

#### func (Laplace) Quantile¶Uses

func (l Laplace) Quantile(p float64) float64

Quantile returns the inverse of the cumulative probability distribution.

#### func (Laplace) Rand¶Uses

func (l Laplace) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Laplace) Score¶Uses

func (l Laplace) 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 / ∂Mu, ∂LogProb / ∂Scale].

Special cases:

Score(0) = [0, -0.5/l.Scale]


#### func (Laplace) ScoreInput¶Uses

func (l Laplace) 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(l.Mu) = 0


#### func (Laplace) Skewness¶Uses

func (Laplace) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (Laplace) StdDev¶Uses

func (l Laplace) StdDev() float64

StdDev returns the standard deviation of the distribution.

#### func (Laplace) Survival¶Uses

func (l Laplace) Survival(x float64) float64

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

#### func (*Laplace) UnmarshalParameters¶Uses

func (l *Laplace) UnmarshalParameters(p []Parameter)

UnmarshalParameters implements the ParameterMarshaler interface

#### func (Laplace) Variance¶Uses

func (l Laplace) Variance() float64

Variance returns the variance of the probability distribution.

### type LogNormal¶Uses

type LogNormal struct {
Mu    float64
Sigma float64
Src   rand.Source
}

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) CDF¶Uses

func (l LogNormal) CDF(x float64) float64

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

#### func (LogNormal) Entropy¶Uses

func (l LogNormal) Entropy() float64

Entropy returns the differential entropy of the distribution.

#### func (LogNormal) ExKurtosis¶Uses

func (l LogNormal) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (LogNormal) LogProb¶Uses

func (l LogNormal) LogProb(x float64) float64

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

#### func (LogNormal) Mean¶Uses

func (l LogNormal) Mean() float64

Mean returns the mean of the probability distribution.

#### func (LogNormal) Median¶Uses

func (l LogNormal) Median() float64

Median returns the median of the probability distribution.

#### func (LogNormal) Mode¶Uses

func (l LogNormal) Mode() float64

Mode returns the mode of the probability distribution.

#### func (LogNormal) NumParameters¶Uses

func (LogNormal) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (LogNormal) Prob¶Uses

func (l LogNormal) Prob(x float64) float64

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

#### func (LogNormal) Quantile¶Uses

func (l LogNormal) Quantile(p float64) float64

Quantile returns the inverse of the cumulative probability distribution.

#### func (LogNormal) Rand¶Uses

func (l LogNormal) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (LogNormal) Skewness¶Uses

func (l LogNormal) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (LogNormal) StdDev¶Uses

func (l LogNormal) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (LogNormal) Survival¶Uses

func (l LogNormal) Survival(x float64) float64

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

#### func (LogNormal) Variance¶Uses

func (l LogNormal) Variance() float64

Variance returns the variance of the probability distribution.

### type LogProber¶Uses

type LogProber interface {
LogProb(float64) float64
}

### type Normal¶Uses

type Normal struct {
Mu    float64 // Mean of the normal distribution
Sigma float64 // Standard deviation of the normal distribution
Src   rand.Source
}

Normal respresents a normal (Gaussian) distribution (https://en.wikipedia.org/wiki/Normal_distribution).

Code:

// 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) CDF¶Uses

func (n Normal) CDF(x float64) float64

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

#### func (*Normal) ConjugateUpdate¶Uses

func (n *Normal) 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 normal distribution, the sufficient statistics are the mean and uncorrected standard deviation of the samples. The prior is having seen strength samples with mean Normal.Mu and strength 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) != 2 or len(priorStrength) != 2.

#### func (Normal) Entropy¶Uses

func (n Normal) Entropy() float64

Entropy returns the differential entropy of the distribution.

#### func (Normal) ExKurtosis¶Uses

func (Normal) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (*Normal) Fit¶Uses

func (n *Normal) 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 (Normal) LogProb¶Uses

func (n Normal) LogProb(x float64) float64

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

#### func (Normal) Mean¶Uses

func (n Normal) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Normal) Median¶Uses

func (n Normal) Median() float64

Median returns the median of the normal distribution.

#### func (Normal) Mode¶Uses

func (n Normal) Mode() float64

Mode returns the mode of the normal distribution.

#### func (Normal) NumParameters¶Uses

func (Normal) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Normal) NumSuffStat¶Uses

func (Normal) NumSuffStat() int

NumSuffStat returns the number of sufficient statistics for the distribution.

#### func (Normal) Prob¶Uses

func (n Normal) Prob(x float64) float64

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

#### func (Normal) Quantile¶Uses

func (n Normal) Quantile(p float64) float64

Quantile returns the inverse of the cumulative probability distribution.

#### func (Normal) Rand¶Uses

func (n Normal) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Normal) Score¶Uses

func (n Normal) 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 / ∂Mu, ∂LogProb / ∂Sigma].

#### func (Normal) ScoreInput¶Uses

func (n Normal) 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)) .


#### func (Normal) Skewness¶Uses

func (Normal) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (Normal) StdDev¶Uses

func (n Normal) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Normal) SuffStat¶Uses

func (Normal) SuffStat(suffStat, samples, weights []float64) (nSamples float64)

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().

#### func (Normal) Survival¶Uses

func (n Normal) Survival(x float64) float64

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

#### func (Normal) Variance¶Uses

func (n Normal) Variance() float64

Variance returns the variance of the probability distribution.

### type Parameter¶Uses

type Parameter struct {
Name  string
Value float64
}

Parameter represents a parameter of a probability distribution

### type Pareto¶Uses

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.


#### func (Pareto) CDF¶Uses

func (p Pareto) CDF(x float64) float64

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

#### func (Pareto) Entropy¶Uses

func (p Pareto) Entropy() float64

Entropy returns the differential entropy of the distribution.

#### func (Pareto) ExKurtosis¶Uses

func (p Pareto) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (Pareto) LogProb¶Uses

func (p Pareto) LogProb(x float64) float64

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

#### func (Pareto) Mean¶Uses

func (p Pareto) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Pareto) Median¶Uses

func (p Pareto) Median() float64

Median returns the median of the pareto distribution.

#### func (Pareto) Mode¶Uses

func (p Pareto) Mode() float64

Mode returns the mode of the distribution.

#### func (Pareto) NumParameters¶Uses

func (p Pareto) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Pareto) Prob¶Uses

func (p Pareto) Prob(x float64) float64

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

#### func (Pareto) Rand¶Uses

func (p Pareto) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Pareto) StdDev¶Uses

func (p Pareto) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Pareto) Survival¶Uses

func (p Pareto) Survival(x float64) float64

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

#### func (Pareto) Variance¶Uses

func (p Pareto) Variance() float64

Variance returns the variance of the probability distribution.

### type Poisson¶Uses

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^(-λ)


#### func (Poisson) CDF¶Uses

func (p Poisson) CDF(x float64) float64

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

#### func (Poisson) ExKurtosis¶Uses

func (p Poisson) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (Poisson) LogProb¶Uses

func (p Poisson) LogProb(x float64) float64

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

#### func (Poisson) Mean¶Uses

func (p Poisson) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Poisson) NumParameters¶Uses

func (Poisson) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Poisson) Prob¶Uses

func (p Poisson) Prob(x float64) float64

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

#### func (Poisson) Rand¶Uses

func (p Poisson) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Poisson) Skewness¶Uses

func (p Poisson) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (Poisson) StdDev¶Uses

func (p Poisson) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Poisson) Survival¶Uses

func (p Poisson) Survival(x float64) float64

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

#### func (Poisson) Variance¶Uses

func (p Poisson) Variance() float64

Variance returns the variance of the probability distribution.

### type Quantiler¶Uses

type Quantiler interface {
Quantile(p float64) float64
}

### type RandLogProber¶Uses

type RandLogProber interface {
Rander
LogProber
}

### type Rander¶Uses

type Rander interface {
Rand() float64
}

### type StudentsT¶Uses

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 prameter 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 ν → ∞.

The standard Student's T distribution is with Mu = 0, and Sigma = 1.

#### func (StudentsT) CDF¶Uses

func (s StudentsT) CDF(x float64) float64

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

#### func (StudentsT) LogProb¶Uses

func (s StudentsT) LogProb(x float64) float64

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

#### func (StudentsT) Mean¶Uses

func (s StudentsT) Mean() float64

Mean returns the mean of the probability distribution.

#### func (StudentsT) Mode¶Uses

func (s StudentsT) Mode() float64

Mode returns the mode of the distribution.

#### func (StudentsT) NumParameters¶Uses

func (StudentsT) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (StudentsT) Prob¶Uses

func (s StudentsT) Prob(x float64) float64

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

#### func (StudentsT) Quantile¶Uses

func (s StudentsT) Quantile(p float64) float64

Quantile returns the inverse of the cumulative distribution function.

#### func (StudentsT) Rand¶Uses

func (s StudentsT) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (StudentsT) StdDev¶Uses

func (s StudentsT) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

The standard deviation is undefined for ν <= 1, and this returns math.NaN().

#### func (StudentsT) Survival¶Uses

func (s StudentsT) Survival(x float64) float64

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

#### func (StudentsT) Variance¶Uses

func (s StudentsT) Variance() float64

Variance returns the variance of the probability distribution.

The variance is undefined for ν <= 1, and this returns math.NaN().

### type Triangle¶Uses

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

Triangle represents a triangle distribution (https://en.wikipedia.org/wiki/Triangular_distribution).

#### func NewTriangle¶Uses

func NewTriangle(a, b, c float64, src rand.Source) Triangle

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) CDF¶Uses

func (t Triangle) CDF(x float64) float64

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

#### func (Triangle) Entropy¶Uses

func (t Triangle) Entropy() float64

Entropy returns the entropy of the distribution.

#### func (Triangle) ExKurtosis¶Uses

func (Triangle) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (Triangle) LogProb¶Uses

func (t Triangle) LogProb(x float64) float64

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

#### func (Triangle) MarshalParameters¶Uses

func (t Triangle) MarshalParameters(p []Parameter)

MarshalParameters implements the ParameterMarshaler interface

#### func (Triangle) Mean¶Uses

func (t Triangle) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Triangle) Median¶Uses

func (t Triangle) Median() float64

Median returns the median of the probability distribution.

#### func (Triangle) Mode¶Uses

func (t Triangle) Mode() float64

Mode returns the mode of the probability distribution.

#### func (Triangle) NumParameters¶Uses

func (Triangle) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Triangle) Prob¶Uses

func (t Triangle) Prob(x float64) float64

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

#### func (Triangle) Quantile¶Uses

func (t Triangle) Quantile(p float64) float64

Quantile returns the inverse of the cumulative probability distribution.

#### func (Triangle) Rand¶Uses

func (t Triangle) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Triangle) Skewness¶Uses

func (t Triangle) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (Triangle) StdDev¶Uses

func (t Triangle) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Triangle) Survival¶Uses

func (t Triangle) Survival(x float64) float64

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

#### func (*Triangle) UnmarshalParameters¶Uses

func (t *Triangle) UnmarshalParameters(p []Parameter)

UnmarshalParameters implements the ParameterMarshaler interface

#### func (Triangle) Variance¶Uses

func (t Triangle) Variance() float64

Variance returns the variance of the probability distribution.

### type Uniform¶Uses

type Uniform struct {
Min float64
Max float64
Src rand.Source
}

Uniform represents a continuous uniform distribution (https://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29).

#### func (Uniform) CDF¶Uses

func (u Uniform) CDF(x float64) float64

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

#### func (Uniform) Entropy¶Uses

func (u Uniform) Entropy() float64

Entropy returns the entropy of the distribution.

#### func (Uniform) ExKurtosis¶Uses

func (Uniform) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (Uniform) LogProb¶Uses

func (u Uniform) LogProb(x float64) float64

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

#### func (Uniform) MarshalParameters¶Uses

func (u Uniform) MarshalParameters(p []Parameter)

MarshalParameters implements the ParameterMarshaler interface

#### func (Uniform) Mean¶Uses

func (u Uniform) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Uniform) Median¶Uses

func (u Uniform) Median() float64

Median returns the median of the probability distribution.

#### func (Uniform) NumParameters¶Uses

func (Uniform) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Uniform) Prob¶Uses

func (u Uniform) Prob(x float64) float64

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

#### func (Uniform) Quantile¶Uses

func (u Uniform) Quantile(p float64) float64

Quantile returns the inverse of the cumulative probability distribution.

#### func (Uniform) Rand¶Uses

func (u Uniform) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Uniform) Skewness¶Uses

func (Uniform) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (Uniform) StdDev¶Uses

func (u Uniform) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Uniform) Survival¶Uses

func (u Uniform) Survival(x float64) float64

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

#### func (*Uniform) UnmarshalParameters¶Uses

func (u *Uniform) UnmarshalParameters(p []Parameter)

UnmarshalParameters implements the ParameterMarshaler interface

#### func (Uniform) Variance¶Uses

func (u Uniform) Variance() float64

Variance returns the variance of the probability distribution.

### type Weibull¶Uses

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) CDF¶Uses

func (w Weibull) CDF(x float64) float64

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

#### func (Weibull) Entropy¶Uses

func (w Weibull) Entropy() float64

Entropy returns the entropy of the distribution.

#### func (Weibull) ExKurtosis¶Uses

func (w Weibull) ExKurtosis() float64

ExKurtosis returns the excess kurtosis of the distribution.

#### func (Weibull) LogCDF¶Uses

func (w Weibull) LogCDF(x float64) complex128

LogCDF computes the value of the log of the cumulative density function at x.

#### func (Weibull) LogProb¶Uses

func (w Weibull) LogProb(x float64) float64

LogProb computes the natural logarithm of the value of the probability density function at x. Zero 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¶Uses

func (w Weibull) LogSurvival(x float64) float64

LogSurvival returns the log of the survival function (complementary CDF) at x.

#### func (Weibull) Mean¶Uses

func (w Weibull) Mean() float64

Mean returns the mean of the probability distribution.

#### func (Weibull) Median¶Uses

func (w Weibull) Median() float64

Median returns the median of the normal distribution.

#### func (Weibull) Mode¶Uses

func (w Weibull) Mode() float64

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¶Uses

func (Weibull) NumParameters() int

NumParameters returns the number of parameters in the distribution.

#### func (Weibull) Prob¶Uses

func (w Weibull) Prob(x float64) float64

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

#### func (Weibull) Quantile¶Uses

func (w Weibull) Quantile(p float64) float64

Quantile returns the inverse of the cumulative probability distribution.

#### func (Weibull) Rand¶Uses

func (w Weibull) Rand() float64

Rand returns a random sample drawn from the distribution.

#### func (Weibull) Score¶Uses

func (w Weibull) 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 / ∂K, ∂LogProb / ∂λ].

Special cases:

Score(0) = [NaN, NaN]


#### func (Weibull) ScoreInput¶Uses

func (w Weibull) 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 (Weibull) Skewness¶Uses

func (w Weibull) Skewness() float64

Skewness returns the skewness of the distribution.

#### func (Weibull) StdDev¶Uses

func (w Weibull) StdDev() float64

StdDev returns the standard deviation of the probability distribution.

#### func (Weibull) Survival¶Uses

func (w Weibull) Survival(x float64) float64

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

#### func (Weibull) Variance¶Uses

func (w Weibull) Variance() float64

Variance returns the variance of the probability distribution.

Package distuv imports 8 packages (graph) and is imported by 48 packages. Updated 2019-12-03. Refresh now. Tools for package owners.