-
Notifications
You must be signed in to change notification settings - Fork 0
/
distributions.go
69 lines (55 loc) · 1.17 KB
/
distributions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package timeout
import (
"golang.org/x/exp/rand"
"gonum.org/v1/gonum/stat/distuv"
)
type ParetoDistribution struct {
*distuv.Pareto
}
func NewParetoDistribution(Xm, Alpha float64) *ParetoDistribution {
return &ParetoDistribution{
Pareto: &distuv.Pareto{
Xm: Xm,
Alpha: Alpha,
},
}
}
func (p *ParetoDistribution) SetSrc(src rand.Source) {
p.Pareto.Src = src
}
func (p *ParetoDistribution) Rand() int {
return int(p.Pareto.Rand())
}
type WeibullDistribution struct {
*distuv.Weibull
}
func NewWeibullDistribution(K, Lambda float64) *WeibullDistribution {
return &WeibullDistribution{
Weibull: &distuv.Weibull{
K: K,
Lambda: Lambda,
},
}
}
func (p *WeibullDistribution) SetSrc(src rand.Source) {
p.Weibull.Src = src
}
func (p *WeibullDistribution) Rand() int {
return int(p.Weibull.Rand())
}
type ExpDistribution struct {
*distuv.Exponential
}
func NewExpDistribution(Rate float64) *ExpDistribution {
return &ExpDistribution{
Exponential: &distuv.Exponential{
Rate: Rate,
},
}
}
func (p *ExpDistribution) SetSrc(src rand.Source) {
p.Exponential.Src = src
}
func (p *ExpDistribution) Rand() int {
return int(p.Exponential.Rand())
}