From 5f052f8d98fe534a37a4c66e96e134e04fa21b87 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 18 Nov 2023 16:10:26 -0800 Subject: [PATCH] Add convenience functions for the "default" normal distribution and bidders distributed thereby. --- auctionsim/defaults.go | 31 +++++++++++++++++++++++++++++++ auctionsim/generators.go | 1 - 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 auctionsim/defaults.go diff --git a/auctionsim/defaults.go b/auctionsim/defaults.go new file mode 100644 index 0000000..dbcf2a8 --- /dev/null +++ b/auctionsim/defaults.go @@ -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)), + } +} diff --git a/auctionsim/generators.go b/auctionsim/generators.go index a67076a..e4c3827 100644 --- a/auctionsim/generators.go +++ b/auctionsim/generators.go @@ -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. */