Documentation
¶
Overview ¶
Package dist provides statistical probability distributions for random variables.
Index ¶
Constants ¶
const ( NaN = 0x7FF8000000000001 Inf = 0x7FF0000000000000 NegInf = 0xFFF0000000000000 )
Nabbed these from math...
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Binomial ¶
type Binomial struct {
// contains filtered or unexported fields
}
Binomial distribution with parameter n and p.
TODO.
type Continuous ¶
type Continuous interface {
Float64() float64
}
func Highpass ¶
func Highpass(c Continuous, low float64) Continuous
func Lowpass ¶
func Lowpass(c Continuous, high float64) Continuous
func Midpass ¶
func Midpass(c Continuous, low, high float64) Continuous
type Discrete ¶
type Discrete interface {
Int63() int64
}
func Ceil ¶
func Ceil(c Continuous) Discrete
func Floor ¶
func Floor(c Continuous) Discrete
func Round ¶
func Round(c Continuous) Discrete
type Dist ¶
type Dist interface { DistP // Q returns the p-quantile of the distribution, this is the inverse CDF function. Q(p float64) (x float64) }
Dist is implemented by all distributions that give the inverse CDF function. Because this is not possible for all distributions, it remains optional.
type Exponential ¶
type Exponential struct {
// contains filtered or unexported fields
}
Exponential distribution with rate of arrival.
func NewExponential ¶
func NewExponential(s rand.Source, lambda float64) *Exponential
func (*Exponential) Float64 ¶
func (e *Exponential) Float64() float64
func (*Exponential) Mean ¶
func (e *Exponential) Mean() float64
func (*Exponential) P ¶
func (e *Exponential) P(x float64) float64
func (*Exponential) Q ¶
func (e *Exponential) Q(p float64) float64
func (*Exponential) String ¶
func (e *Exponential) String() string
type HyperExponential ¶
type HyperExponential struct {
// contains filtered or unexported fields
}
HyperExponential distribution with k rates of arrival.
func NewHyperExponential ¶
func NewHyperExponential(s rand.Source, probs, lambdas []float64) *HyperExponential
func (*HyperExponential) Float64 ¶
func (e *HyperExponential) Float64() float64
func (*HyperExponential) Mean ¶
func (e *HyperExponential) Mean() float64
func (*HyperExponential) SecondMoment ¶
func (e *HyperExponential) SecondMoment() float64
func (*HyperExponential) String ¶
func (e *HyperExponential) String() string
func (*HyperExponential) Var ¶
func (e *HyperExponential) Var() float64
type LogNormal ¶
type LogNormal struct {
// contains filtered or unexported fields
}
LogNormal distribution with mean and standard deviation.
See:
http://stackoverflow.com/questions/23699738 http://blogs.sas.com/content/iml/2014/06/04/simulate-lognormal-data-with-specified-mean-and-variance.html
type Normal ¶
type Normal struct {
// contains filtered or unexported fields
}
Normal distribution with mean and standard deviation.
type Poisson ¶
type Poisson struct {
// contains filtered or unexported fields
}
Poisson returns random numbers according to a poisson distribution.
The poisson distribution models the number of arrivals in a set time interval when the inter-arrival times are exponentially distributed. This is why
type Stairs ¶
type Stairs struct {
// contains filtered or unexported fields
}
Stairs returns the index of the first probability value that exceeds the random value between 0.0 and 1.0.
For example, given the following list:
[0.0, 0.3, 0.6, 0.6, 0.9]
We can imagine the following stairs, with indices from 0 to 4.
. .____.____| .____| .____| 0 0.3 0.6 0.6 0.9 0 1 2 3 4
The probability for index 0 and 3 is 0.0. The probability for the rest is is the value minus the previous divided by the last value in the list, in this case 0.9. The indices 1, 2, and 4 all have the same probability then. Therefore, we get the same result if we pass in the list:
[0, 3, 6, 6, 9]
The only requirement on the numbers in the list are that they are monotonically increasing. Failing this requirement will cause NewStairs to panic.
type Uniform ¶
type Uniform struct {
// contains filtered or unexported fields
}
Uniform gives a uniform distribution between a and b.
type UniformDiscrete ¶
type UniformDiscrete struct {
// contains filtered or unexported fields
}
UniformDiscrete gives a discrete uniform distribution between a and b.
func NewUniformDiscrete ¶
func NewUniformDiscrete(s rand.Source, a, b int64) *UniformDiscrete
NewUniformDiscrete returns a discrete uniform distribution in [a, b). Note: this will not work if (b-a) is greater than 2**63.
func (*UniformDiscrete) Int63 ¶
func (u *UniformDiscrete) Int63() int64
func (*UniformDiscrete) Mean ¶
func (u *UniformDiscrete) Mean() float64
func (*UniformDiscrete) P ¶
func (u *UniformDiscrete) P(x int64) (p float64)
func (*UniformDiscrete) Q ¶
func (u *UniformDiscrete) Q(p float64) (x float64)
func (*UniformDiscrete) String ¶
func (u *UniformDiscrete) String() string