Skip to content
CoreSource checked

Monte Carlo Integration

Approximates integrals by averaging random samples.

Quick Facts

Compact metadata for implementation and discovery.

Category
Numerical Methods
Difficulty
Intermediate
Family
Stochastic Integration
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
2
Code example
Ready
Visualization
Ready

Overview

Monte Carlo Integration estimates an integral from randomly sampled function values, which is especially useful in high-dimensional domains.

Core Concepts

random samplesample meandomain volumevariance

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(samples)

Average

O(samples)

Worst

O(samples)

Space

O(1)

When to Use

  • Use when dimension is high or deterministic grids are too expensive.
  • Use when high-dimensional integration is a central requirement.

When Not to Use

  • Avoid when a smooth low-dimensional integral can be solved faster with quadrature.
  • Avoid when roundoff, conditioning, or discontinuities dominate the result.

What It Does

  • Draws random samples
  • Evaluates the integrand
  • Scales the sample average by domain volume

Use Cases

  • High-dimensional integration
  • Uncertainty estimates
  • Rendering estimators

Inputs

  • Function
  • Sampling domain
  • Sample count

Outputs

  • Integral estimate

Key Formulas (1)

Monte Carlo integral

integral ≈ volume(domain) · mean(f(samplei))
integral ~= volume(domain) * mean(f(sample_i))

Scales the average sampled value by the size of the domain.

Pseudocode

  1. 1.Draw random points from the integration domain
  2. 2.Evaluate the function at each point
  3. 3.Average the values
  4. 4.Multiply by domain volume
  5. 5.Report estimate and optional uncertainty

Canonical Example

Input
sample f(x)=x^2 on [0,1]
Output
estimate near 0.333
Explanation
The sample average approximates the area under the curve.

Implementation Notes

  • Track sample variance along with the mean estimate.
  • Compare against a small hand-checkable case before scaling up.
  • Keep a tiny example with expected output beside the implementation.

Common Pitfalls

  • Using biased samples without weighting gives the wrong integral.
  • Ignoring conditioning can make a correct method return unreliable numbers.
  • Not defining boundary, empty, or degenerate inputs before implementation.

Interactive Mechanism Walkthrough

Iterative Convergence & State Trajectory

Show random points under a curve contributing to an average area estimate.

Monte Carlo Integration mechanism walkthrough step 1 of 5x₀x₁x₂x*
Step 1 of 5: Draw random points from the integration domain
numeric-iteration

Notes

Error decreases slowly, so variance reduction is often important.

Sources (1)

What each reference supports for this entry.

Metropolis and Ulam 1949

Paper

Foundational paper describing the Monte Carlo method.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Monte Carlo integration estimates integrals with random samples.

Tags

Numerical MethodsSamplingStochasticEstimation