My task is simple.
Calculate the average value for 10^7 dice throws using computer pseudo-random-number-generator.
x := RandomInteger[{1, 6}]
gives me one random value.
xn[n_] := 1/n Sum[x, {j, 1, n}]
gives me the average value for n throws.
If I set n = 10^6
its just fine and I get a number around 3.5,
but as soon as I set n = 10^7
, I get an integer between 1 and 6 with a dot after it, which means that Mathematica rounds the result, right?. The problem is, that Mathematica doesnt even start calculating those 10^7 values.
Of course, I could just sum 10 times xn[10^6]
and divide it by 10, but I want it to work with n = 10^7
right away.
{}
button above the edit window. The edit window help button?
is useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$1
? Curious mostly because getting an average of $1$, or even something that rounds to $1$, after ${10}^{7}$ dice throws is absurdly unlikely, so it'd be weird if Mathematica's logic allowed for that result to be returned, even under some sort of approximation logic. $\endgroup$