9/24/2023 0 Comments Monte carlo simulation pi![]() This method of filling coordinate points, counting them, and using the difference or ratio of the counts is called the Monte Carlo method or approximation. The more dots created, the better the accuracy of our value for area ratio. If it fits, increase the count of dots and try to make more for some amount of time. To make the “dots” we can randomly make a value and see if it would fit as a coordinate within the shape we’re trying to fill. Of course, we can’t completely fill the area of both shapes with dots but we could get enough of them in there to give a useful ratio between the circle and the square. The area ratio is:Īrea ratio = (dots in circle) / ((dots in circle) + (dots only in square)) And, in the equation shown above, we can discover pi if we have this ratio. If we count the number of dots placed in both the circle and the square, we could find the area ratio between the two shapes. ![]() We’ll try to cover the area of both shapes with as many dots as possible. What if we had a lot of really small dots that we could fill into the circle and into the parts of the square that the circle didn’t cover. That’s the dilemma! We need to know the area of the circle to find out what pi is and we need the value of pi the find the area of the circle! Dots, lots of dots We know the area of the square, sure enough it’s 4, but what’s the area of the circle? So then… area ratio = (area of circle) / (area of square) Well, we can see that if we knew the area of both the circle and the square we could find out what the value of pi is! It’s simply this: pi = (area of circle) / (area of square) * 4 Circle and squareĪn interesting relationship between the circle and the square is that the area of the circle divided by the area of the square is:Īrea ratio = (pi * (r ** 2)) / ((r * 2) ** 2) = pi / 4 We don’t know what pi is so we can arrange a relationship between the area of the circle and the area of the square to solve for the value of pi. The area of the circle is pi * (r ** 2) and the area of the square then is (r * 2) ** 2. If we say that the radius, called r, of circle is 1 then the length of each side of the square is 2, or 2 * r. Ok, let’s pretend that a circle fits inside a square where the edge of the circle touches the sides of the square. Approximate the value of pi using your micro:bit! Thinking about it…
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |