Smokemotes
#8
(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.
Reply


Messages In This Thread
Smokemotes - by James D Jarvis - 01-18-2023, 10:16 PM
RE: Smokemotes - by James D Jarvis - 01-18-2023, 11:47 PM
RE: Smokemotes - by bplus - 01-19-2023, 02:27 AM
RE: Smokemotes - by James D Jarvis - 01-19-2023, 02:43 AM
RE: Smokemotes - by bplus - 01-19-2023, 04:15 AM
RE: Smokemotes - by James D Jarvis - 01-19-2023, 03:16 PM
RE: Smokemotes - by bplus - 01-19-2023, 06:11 PM
RE: Smokemotes - by RokCoder - 01-19-2023, 01:01 PM
RE: Smokemotes - by James D Jarvis - 01-19-2023, 03:03 PM
RE: Smokemotes - by James D Jarvis - 01-19-2023, 07:14 PM



Users browsing this thread: 4 Guest(s)