Monte Carlo estimation of PI


Author Message
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 427
Posted: 09:15am 10 Sep 2020      

  Volhout said  GerryL's algorythm uses floats (not pixels).
So in theory it should (give sufficient time) reach infinite resolution.

It is the randomizer I am worried about. Typically these are build up around 16bit shift registers (or 32 bit). Meaning that whatever scaling you apply, there are only so many different values possible. Even with a good distribution (all values have equal chance), there are only so amny.

It should be easy to check if that is the case. In stead of rando numbers, use for-next loops for both x and y with significant resolution.

example: x = 0 to 1 step 0.000001

And see where you end up ...


When I compared CMM2 to Pyhton - using the RANDOM library in Python (53-bit precision floats) the outcomes are comparable after 10,000,000 iterations.

My method I published upthread was based on a box of certain size and pixels -- but I have now tested this using the same algorithm in both CMM2 and Python (a quarter box of side 1 unit) (which is how this seems to be implemented everywhere).

For fun, I've not got CMM2 producing random integers between 1,100 --- and currently is working through 100,000,000 iterations.  I'll knock up a BASIC prog to histogram the results.

Unless I'm missing something -- I dont have any worries over the random number generator in the CMM2 --> interesting how threads get a life of their own.