"Creativity is the ability to introduce order into the randomness of nature" - Eric Hoffer
This program is about simulation using monte carlo algorithm in order to estimate
Finished state of the program
The idea behind this program is to simulate randomized dot marking in each timestep in a space of a circle that is enclosed within a square. We count and separate the dots as follows:
- Blue dots: the dots that lie within the circle.
- Red dots: the dots that lie outside the circle and within the square.
The ratio of circle and square area will be approximated better to its true value as the number of dots gets larger. Because the same probability of dots falling in each pixel in the square, we can conclude that portion of the dots in each area correlates linearly with the area of circle and square, as follows:
If we take the ratio of circle and square area:
where:
Therefore to get
- Creating graphical user interface using
javax.swing.JFrame
library. - Creating simple monte carlo simulation based on uniform distribution.
This is the project as part of learning process using Java programming language. The program is not finished yet, because there is 'freeze' effects due to the waiting time for the finished state to be displayed. In the next version I will add event listeners
to better visualize the process of the simulation.
The simulation is relying on java.util.Random
library. It leaves the implementation of generating the events. In the next program I will try to build the generator using some custom probability density function to simulate other stochastic events.
Horstmann, C., 2018. Big Java. New York: Wiley.