I managed to speed it up a bit and let it run for 100,000 samples, but it came consistently to about -0.015 of pi. Since it never (at the end) went above the true value of pi in the 3 tests that I did, seemingly, the random number generator in Scratch is probably only pseudo-random, or I did not do enough tests. Is there any part of statistics that might predict the value of pi that I got with 100,000 tests to be within this range, however?
To make it a little more efficien, you could make it so it goes line by line, with the script copied within the forever loop. That i good for optomization.
This is cool and a great idea. If you could show the math a bit and advise the looker to be patient they will get it. Not many people have dowloaded it so i fear not many lookers got it. Look at my game Susa you will like it!
From statistics, we can work out that both the mean and the variance of the number of points in the circle is n*pi/4. That means that the standard deviation of the estimate of pi will be about pi/sqrt(n). After 10000 samples, you expect to be within about +- 0.03 of pi.
Download the one sprite and 2 scripts of "pi from area" and open it in Scratch
Project Notes
This project estimates pi by comparing the area of a circle to the area of a square, dropping points randomly in a square to esitmate area.
This is not an efficient way to compute pi, but it nicely illustrates random sampling.
Comments
You need to be logged in to post comments
Add a Comment
I used a very similar approach to this in my C++ class at school to approximate the area of pi, only you could pick how many random points.
Where did you go?
you live un santa cruz? lol me too
I managed to speed it up a bit and let it run for 100,000 samples, but it came consistently to about -0.015 of pi. Since it never (at the end) went above the true value of pi in the 3 tests that I did, seemingly, the random number generator in Scratch is probably only pseudo-random, or I did not do enough tests. Is there any part of statistics that might predict the value of pi that I got with 100,000 tests to be within this range, however?
To make it a little more efficien, you could make it so it goes line by line, with the script copied within the forever loop. That i good for optomization.
This is cool and a great idea. If you could show the math a bit and advise the looker to be patient they will get it. Not many people have dowloaded it so i fear not many lookers got it. Look at my game Susa you will like it!
Oh, wait, I see the variable name now, sorry.
Isn't Pi 3.14159... not 314,159...? Or will it fix that?
Can you help me you're a forum moderator (link to forums)">(link to forum)
From statistics, we can work out that both the mean and the variance of the number of points in the circle is n*pi/4. That means that the standard deviation of the estimate of pi will be about pi/sqrt(n). After 10000 samples, you expect to be within about +- 0.03 of pi.
its a good priject but i am actually suprised at how ineffiecient it is.
this is similar to my project
cool