Approximating Probability using Monte Carlo Method
1 次查看(过去 30 天)
显示 更早的评论
I have a problem where I need to sample two random points (x and y) unifromrly from the unit square [0,1] x [0,1]
I need to use the Monte Carlo Method to approximate the probability that (the 2 norm of x-y) ||x-y||_2 is smaller or equal to 1/2
Anyone has an idea on how to go on about this?
3 个评论
John D'Errico
2020-4-2
An interesting question is how to compute that result analytically, without recourse to a simulation. Hmm...
'Til then so you can verify your result, I get with a sample size of 1e8 points:
p =
0.48335794
With a predicted standard deviation on that estimate of
s =
4.99722965090615e-05
回答(1 个)
Image Analyst
2020-4-2
Hint:
xy = rand(1000000, 2);
or
numPoints = 1000000;
x = rand(numPoints, 1);
y = rand(numPoints, 1);
Look up norm in the help.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!