"MonteCarloSimulator" is an object dedicated to the simulation of random phenomena on the basis of random variables generators and functions describing the simulated statistical process. Thus, the random variables and the numerical functions defined by user are updated for each of the simulation steps through the arithmetic expressions defined in anonymous functions. The reference to the previous values of a function is possible through the definition of buffers storing its last values.
Any function can refer to the variables, function buffers or previously defined functions by defining them as input arguments of its anonymous function. These input arguments must be defined in a specific order:
1) Other functions
2) Function buffers
3) Random variables
Then, for each of the simulation steps, all the arguments from the list above are extracted and injected in the arithmetic expression of the anonymous function corresponding to the function to evaluate. The simulation is performed for a specified number of realizations with the display of the estimated time remaining thanks to a timer wait bar.
The source folder includes the following examples:
- Buffon’s needle (short needle case)
- Gyroscope random walk (integration of angle increments with white noise)
- Filtering integrator (two meaning average masks)
- German tank problem (test of an estimator)
- Bi-dimensional random walk
The internal timer wait bar and the video recorder sources are enable at the following addresses:
Video demonstration links:
Eric Ogier (2022). Monte-Carlo Simulator (https://www.mathworks.com/matlabcentral/fileexchange/56509-monte-carlo-simulator), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!