01-19-2023, 03:16 PM
(01-19-2023, 04:15 AM)bplus Wrote: +1 OK not seen that before, works great!
Code: (Select All)Dim As Long a(-11 To 11)
For i = 1 To 100000
r = Int(Rnd * 11) - Int(Rnd * 11)
a(r) = a(r) + 1
Next
For i = -11 To 11
Print String$(Int(a(i) / 1000), "*")
Next
You beat me to the code that demonstrates a bell curve at work. You shouldn't ever get -11 or 11 with that code however (unless rnd bumps a bit over at some point).
You can alter the distribution on the curve by changing the range of elements used.
These would all produce a score of 2 to 20 but have different looking result curves:
Code: (Select All)
r1 = Int(1 + Rnd * 10) + (1 + Rnd * 10)
r2 = Int(1 + Rnd * 12) + (1 + Rnd * 8)
r3 = Int(1 + Rnd * 8) + Int(1 + Rnd * 8) + Int(Rnd * 5)
run enough times and r1 is the most pronounced curve with most results coming in the middle.
r2 will have a flatter curve than r1 with a wider range of likely results with a collapsing chance of getting the rarer results (2,3,19,and20) , and r3 should be flatter than that.