I need to manipulate random to produce a statistical average with the shape of a bell curve, here is my attempt:
Function slopedrand(max As Single, bias As Single) As Integer
Dim count As Single = 0
While count < bias
max = rand.NextDouble() * max
count += rand.NextDouble()
End While
Return rand.NextDouble() * max
End Function
Function bulgedrand(min As Single, max As Single, bulge As Single, bias As Single)
Dim negative = bulge - min
Dim positive = max - bulge
Dim nr = min + slopedrand(negative, bias)
Dim pr = max - slopedrand(positive, bias)
Return rand.NextDouble() * (pr - nr) + nr
End Function
however, given that I suck at math, all it produces is stuff like this: https://i.stack.imgur.com/4YTba.png
which is more like a bulge...
Since it feels like my skull is boiling, maybe somebody here has figured out how to accomplish what I need and will spare me from further attempts of thinking?
(the example is given in vb.net since it was quick to prototype on but any language is welcome)