Implementation in Matlab of the Monte Carlo Method

Implementation in Matlab of the Monte Carlo Method thumbnail
Monte Carlo estimation predicts the distribution of unknown parameters.

The Monte Carlo method is a mathematical estimation procedure to estimate the distribution of unknown parameters in a relationship, knowing the distribution of existing parameters. The Monte Carlo method leverages the power of computing to randomly estimate combinations of different input parameters and estimate the distribution of an output parameters. The optimized vector operations in MATLAB makes Monte Carlo estimation simple to program.

  1. Monte Carlo Method

    • The procedure for Monte Carlo simulations is this: guess a set of known parameters from a random distribution and estimate other parameters or future results from these random guesses. When repeated a number of times, the Monte Carlo simulation can give an accurate range of possibilities, as well as their probability. The Monte Carlo method is best suited to linear relationships where only one parameters is unknown.

    Setup

    • Begin preparing for a Monte Carlo simulation by examining the equation for the relationship you wish to simulate. For example, consider, "A/B sin (C theta) = X." The parameters A, B and C should be known, and the angle theta can be estimated across the range 0 to 2 pi. You need to know the range of the parameters A, B and C as well as how possible values are distributed through the range. For example, A and B may be uniformly distributed between 5 and 10, and C may be normally distributed around 2 with a variance of 1. You will also need to decide on the appropriate number of trials to properly estimate the potential distribution of X.

    MATLAB Procedure

    • The MATLAB "rand()" function draws pseudorandom numbers in a uniform distribution over the interval (0,1).

      nTrials = 1000;
      A = 5rand(nTrials,1) + 5;
      B = 5
      rand(nTrials,1) + 5;

      The MATLAB "normrnd()" function draws pseudorandom number from a normal distribution.

      C = normrnd(2,1,nTrials,1);

      The range of the angle theta is estimated between 0 and 2 pi at an internal of 0.05.

      theta = 0:0.05:2*pi;

      The result X will be a matrix of dimension nTrials by length(theta).

      X = (A./B) sin( C theta) ;

    Limitations

    • The Monte Carlo method is limited to simulating mathematical relationships that are known, where most of the parameters can be estimated from a known distribution. Linear relationships work best, as error in estimation can grow very large in nonlinear relationships. Relationships with a large number of parameters or large ranges of distributions may take a very long time to estimate using the Monte Carlo method.

Related Searches

References

  • Photo Credit Goodshoot/Goodshoot/Getty Images

Related Ads

Featured
View Mobile Site