Articles of monte carlo

Why Monte Carlo integration is not affected by curse of dimensionality?

What is the common sense explanation behind that fact that MC integration is free of “curse of dimensionality” in contrast to deterministic integration rules (e.g. trapezoidal rule)?

Simple Monte Carlo Integration

I am trying to use Monte Carlo Integration, which is nicely described in the answer here (Confusion about Monte Carlo integration). I am using Monte Carlo Integration to evaluate $\int_0^1x^2\,dx$. I set $w(x) = f(x)/g(x) = x^2/2x = x/2$ Then, I solved for $(1/n)\sum_i^nw(x_n) = (1/n)\sum_i^nx/2$ However, I do not know if this is a […]

Monte Carlo double integral over a non-rectangular region (Matlab)

I want to evaluated the following integral using Monte Carlo method: $$\int_{0}^{1}\int_{0}^{y}x^2y\ dxdy $$ What I tried using Matlab: output=0; a=0; b=@(y) y; c=0; d=1; f=@(x,y) x^2*y; N=50000; for i=1:N y=c+(d-c)*rand(); x=a+(b(y)-a)*rand(); output=output+f(x,y); end output=0.5*output/N; % 0.5 because it’s the area of the region of integration fprintf(‘Value : %9.8f\n’,output); However this code didn’t give me […]

Estimate function f(x) in high-dimensional space

I’m working on a problem of estimating a function $y=f(x): \mathbb{R}^d \rightarrow \mathbb{R}$. Namely, I have an unknown function $f(x)$ (like a black box), what I can do is to input $x^{(i)}$ to it, and obtain $y^{(i)}$ ($i=1,2,\cdots, N$). Then I get a dataset $(x^{(i)}, y^{(i)})$ and am able to fit a function on it. […]

Expected Value and Variance of Monte Carlo Estimate of $\int_{0}^{1}e^{-x}dx$

Given the integral: $I=\int_{0}^{1}e^{-x}dx$, use standard Monte Carlo with 1000 random numbers and repeat the simulation 1000 times. (a) What is the expected value and variance of the simple Monte Carlo estimate of I ? I wrote the following to calculate the Monte-Carlo approximation to the integral: a=0; b=1; n=1000; x=a+(b-a)*rand(n,1); q=1/(b-a); f=exp(-x); i=mean(f./q) How […]

Roll an N sided die K times. Let S be the side that appeared most often. What is the expected number of times S appeared?

For example, consider a 6 sided die rolled 10 times. Based on the following monte-carlo simulation, I get that the side that appears most will appear 3.44 times on average. n = 6 k = 10 samples = 10000 results = [] for _ in range(samples): counts = {s:0 for s in range(n)} for _ […]

Why does Monte-Carlo integration work better than naive numerical integration in high dimensions?

Can anyone explain simply why Monte-Carlo works better than naive Riemann integration in high dimensions? I do not understand how chosing randomly the points on which you evaluate the function can yield a more precise result than distributing these points evenly on the domain. More precisely: Let $f:[0,1]^d \to \mathbb{R}$ be a continuous bounded integrable […]

Monte-Carlo simulation with sampling from uniform distribution

I used to work with Monte-Carlo simulations for a while. In my case, I generated random data for a variety of input parameters according to uniform distributions (with non-negative support), say for example two variables $a$ and $b$ where data is generated: $a_1, \dots, a_n \leftarrow U(1,2)$ and $b_1, \dots, b_n \leftarrow U(4,5)$. Eventually, I […]

Probability that a stick randomly broken in two places can form a triangle

Randomly break a stick (or a piece of dry spaghetti, etc.) in two places, forming three pieces. The probability that these three pieces can form a triangle is $\frac14$ (coordinatize the stick form $0$ to $1$, call the breaking points $x$ and $y$, consider the unit square of the coordinate plane, shade the areas that […]

Approximating $\pi$ using Monte Carlo integration

I need to estimate $\pi$ using the following integration: $$\int_{0}^{1} \!\sqrt{1-x^2} \ dx$$ using monte carlo Any help would be greatly appreciated, please note that I’m a student trying to learn this stuff so if you can please please be more indulging and try to explain in depth..