PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabs
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry

More from Math Visualization

Other simulators in this category — or see all 84.

View category →
NewUniversity / research

PCA / SVD Geometry

Covariance ellipse and SVD view of dimensionality reduction: principal components, explained variance, and rank-1 reconstruction error.

Launch Simulator
NewUniversity / research

Gradient Descent Optimizers

Compare SGD, momentum, and Adam on a curved loss landscape; tune learning rate, curvature, stability, and iteration count.

Launch Simulator
NewUniversity / research

Gaussian Mixture EM Algorithm

Expectation-maximization for a two-component Gaussian mixture: responsibilities, E/M steps, likelihood, and covariance ellipses.

Launch Simulator
NewUniversity / research

Support Vector Machine Margin

Hard/soft-margin SVM sketch with C penalty, hinge loss, support vectors, decision boundary, and margin bands.

Launch Simulator
NewUniversity / research

Bayesian Updating / Conjugate Priors

Beta-binomial Bayesian updating with prior/posterior curves, posterior predictive probability, and credible intervals.

Launch Simulator
NewUniversity / research

Markov Chain Mixing

Three-state Markov chain with transition matrix, stationary distribution, total variation distance, detailed-balance cue, and spectral-gap proxy.

Launch Simulator
PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Math Visualization/Monte Carlo Integration & Variance Reduction

Monte Carlo Integration & Variance Reduction

Monte Carlo integration estimates an integral as an average over random samples, so the typical error decreases like 1/sqrt(N). This simulator compares three unbiased estimators for a one-dimensional integral: plain uniform sampling, importance sampling with q(x) shaped like the exponential envelope, and stratified sampling that forces coverage across subintervals. The convergence plot shows absolute error versus N, while the standard-error readouts reveal how variance reduction changes the constant in front of the same asymptotic rate.

Who it's for: Numerical methods, uncertainty quantification, statistics, computational physics, data science, and scientific computing courses.

Key terms

  • Monte Carlo integration
  • Variance reduction
  • Importance sampling
  • Stratified sampling
  • Standard error
  • Convergence rate

All three estimators are unbiased for this one-dimensional integral, but their variance differs. Importance sampling helps when q(x) resembles the integrand shape; stratification reduces random clumping by forcing coverage across the interval.

Live graphs

Integral and sampling

1200
4.5
0.35
12

Random stream

7

Measured values

Reference integral0.220362
Plain MC error0.001548
Importance error0.000481
Stratified error0.000370

How it works

Monte Carlo integration simulator comparing plain uniform sampling, importance sampling, and stratified sampling with convergence near 1/sqrt(N).

Key equations

Plain MC: I ≈ (1/N) Σ f(U_i), U_i ~ Uniform(0,1)
Importance: I = E_q[f(X)/q(X)], stratified: sample inside each interval

Frequently asked questions

Does variance reduction beat the 1/sqrt(N) rate?
For ordinary independent Monte Carlo estimators, the asymptotic rate is still 1/sqrt(N). Variance reduction improves the variance constant, so the same number of samples can give a much smaller error.
When does importance sampling help?
It helps when the proposal density q(x) places samples where f(x) contributes most and the weights f(x)/q(x) do not fluctuate too much. A poor proposal can increase variance instead.