Add convenience functions for the "default" normal distribution and bidders distributed thereby.
This commit is contained in:
parent
62c5f5fc0e
commit
5f052f8d98
31
auctionsim/defaults.go
Normal file
31
auctionsim/defaults.go
Normal file
@ -0,0 +1,31 @@
|
||||
package auctionsim
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
/**
|
||||
* NormalestDistribution returns a NormalDistribution with a new rand.Rand
|
||||
* behind it (randomly seeded), with standard deviation of 1 and mean of 0.
|
||||
*/
|
||||
func NormalestDistribution() *NormalDistribution {
|
||||
return &NormalDistribution{
|
||||
Rand: rand.New(rand.NewSource(int64(rand.Uint64()))),
|
||||
StdDev: 1,
|
||||
Mean: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NormalestBidderGenerator returns a BidderGenerator that returns an infinite
|
||||
* number of Bidders with infinite cash, and values and errors normally
|
||||
* distributed around 0.
|
||||
*/
|
||||
func NormalestBidderGenerator() BidderGenerator {
|
||||
d := NormalestDistribution()
|
||||
return &BiddersFromDistributions{
|
||||
Values: d,
|
||||
Irrationalities: d,
|
||||
Bankrolls: ConstDistribution(math.Inf(1)),
|
||||
}
|
||||
}
|
@ -79,7 +79,6 @@ func (n *NormalDistribution) Draw() (float64, bool) {
|
||||
return n.Rand.NormFloat64() * n.StdDev + n.Mean, true
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ConstDistribution is a Distribution that always returns the same value.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user