Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Help limiting my Monte Carlo Solution

1 vue (au cours des 30 derniers jours)
Mike
Mike le 16 Mar 2014
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hello,
I have to write a code to determine a Monte Carlo solution for a PDE problem. The range goes from zero to pi and the limiting factor is the sin wave. My problem that i am experiencing is that my current code stops at on and not the limit of the sin wave. Can someone take a look at the code and see where i made my mistake?
clear; clc;
n = 1000;
x = linspace(0,1,n);
Xinside = [];
dist_X = [];
figure(1)
clf;
syms p
bc = sin (p);
Range = [0 pi];
h = ezplot(bc,Range);
hold on
distance = zeros(0,1,n);
for t = 1:n
a = 0;
b = 1;
Xn = a + b*rand();
Xn(t) = (Xn + Xn)<=1;
plot(Xn);
%distance(t) = sum(distance(1:t) <=1);
%est_pi = 4*Xinside(1:t)./(1:t);
%plot(est_pi);
ylabel('estimation')
xlabel('iteration')
end
hold off

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by