Post Reply 
little math/programming problems April 2023
05-03-2023, 07:10 AM (This post was last modified: 05-03-2023 07:11 AM by ThomasF.)
Post: #6
RE: little math/programming problems April 2023
(05-02-2023 08:03 PM)David Hayden Wrote:  Here's my C++ code. Does anyone spot a problem? Maybe this is a case of rand() showing it's limitations?

Hi David!

I assume this is due to the limitations of rand().
With different seeds I get the following result (ie your code but added seed initialization).
Code:
  srand (time(NULL));

Code:
Average of 5.48456 rolls starting with 5 dice
Average of 5.48837 rolls starting with 5 dice
Average of 5.48826 rolls starting with 5 dice

Using another random generator (PCG), I get the following result:
Code:
Average of 5.49419 rolls starting with 5 dice
Average of 5.49255 rolls starting with 5 dice
Average of 5.49275 rolls starting with 5 dice

Edit: All runs used 5 dice and 10M simulations.

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: little math/programming problems April 2023 - ThomasF - 05-03-2023 07:10 AM



User(s) browsing this thread: 1 Guest(s)