Integral Monte Carlo (estimativa)
- Created by
- Renato Passos, Eng. de Software
- Reviewed by
- Renato Passos, Eng. de Software
Last updated: Apr 18, 2026
Formula
MC hit-or-miss
About this calculator
The Monte Carlo Integration Calculator (hit-or-miss) numerically estimates the value of a definite integral using statistical simulation. Instead of deterministic methods, it generates random points within a rectangle that encloses the function curve. The proportion of points falling below the curve relative to the total points is multiplied by the rectangle area, providing an approximation of the area under the curve.
The hit-or-miss method works as follows: define a rectangle containing the integration region (from 'a' to 'b' on the x-axis and from 0 to a maximum value of the function). Generate N random points uniformly distributed inside this rectangle. Count how many points are below the curve (y <= f(x)). The estimated integral is (count / N) * rectangle area. Larger N yields more accurate estimates.
Use this calculator when you need a quick approximation of complex integrals or functions without known antiderivatives. It is useful in engineering, physics, and finance, where analytical integrals are impractical. It works well for continuous functions on closed intervals. It is not recommended for improper integrals or functions with abrupt discontinuities without adaptation.
Cautions: accuracy depends on the number of points (N). For high precision, use large N (thousands or millions). The method is probabilistic: results vary between runs. For functions with narrow peaks, the estimate may be inefficient. Consider using importance sampling if the function varies widely. Always cross-check with a deterministic method when possible.
Frequently asked questions
How many points should I use for good accuracy?
For errors below 1%, use at least 10,000 points. For higher precision, increase to 100,000 or more. The error decreases with the square root of N.
Why do results vary each time I run?
The method uses random numbers. Each simulation generates different points, so the result fluctuates. To reduce variation, increase N or use a fixed seed.
Does this calculator work for improper integrals?
Not directly. Integrals with infinite limits or singularities need transformation or specialized methods. The hit-or-miss method assumes a finite rectangle.
Can I use it for discontinuous functions?
Yes, as long as the function is bounded and the rectangle contains all discontinuities. However, accuracy may be lower. Check that the rectangle area is correct.
What is the difference between hit-or-miss and importance sampling?
Hit-or-miss samples uniformly in the rectangle. Importance sampling concentrates points where the function is large, reducing variance. Hit-or-miss is simpler but less efficient for peaked functions.