Monte Carlo estimation of PI


Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6546
Posted: 10:43pm 08 Sep 2020      

As far as MMBasic is concerned,
There is no need to use INT at all

x=RND*LENGTH   ' random between 0 and Length
y=RND*LENGTH
d=SQR(x^2+y^2)          ' calculate the radius


Plotting with floats is OK.

I am not sure if staying with floats is true to the algorithm but it does help the accuracy a bit.

Jim