Add convenience functions for the "default" normal distribution and bidders distributed thereby.

This commit is contained in:
Kistaro Windrider 2023-11-18 16:10:26 -08:00
parent 62c5f5fc0e
commit 5f052f8d98
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8
2 changed files with 31 additions and 1 deletions

31
auctionsim/defaults.go Normal file
View 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)),
}
}

View File

@ -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.
*/