Gaussian probability density using Monte Carlo technique and Rectangle method

   In this example, we want to find the value of the integral between the two values a and b. We will use the Monte Carlo method MC and the Rectangle method, called Riemann sum. The related colored part represents the probability that an event would occur between the two values a and b. The first technique uses random numbers and the second method uses Rectangles. For the second method, we sum the values of successive and discrete numbers Σexp(xi)2; whereas the Monte Carlo technique uses the sum of random numbers Σ exp(xr)2 generated by chance. The number of iterations for MC method is the number of the steps for the Rectangle method. The Gaussian (Normal distribution) exp(-x2) must be normalized to 1 in order to represent the probability density; that is ∫ C dx exp(- x2) = 1. This leads to C = 1/2 sqrt(π).
Source code


Average probability for an event; using Monte Carlo technique and Rectangle method under PHP scripts


Enter a lower limit value:
Enter an upper limit value:
Enter a large integer