optimization - Monte Carlo simulation with condition loop in MATLAB -
i physicist.
i have written code on monte carlo simulation condition loop.
i getting error in running simulation code. want consider positive value of simulation result. when run code, error.
i running 10000 iterations , have 5 parameters such a,b,c,d , e. generating random number each parameter using variance , mean of every parameter of normal distribution.
the code follows:
n = 10000; constant = 5; arand = (3*10^(12)*randn(1,n)) + 7*10^(6)*ones(1,n); brand = (9*randn(1,n)) + 17*ones(1,n); crand = (2*10^(-4)*randn(1,n)) + 0.2*ones(1,n); drand = (0.0017*randn(1,n)) + 0.50*ones(1,n); erand = (0.00004*randn(1,n)) + 1.5*ones(1,n); if p1 > 0 p1 = constant*arand.*brand.*crand.*drand.*(1/erand) end plot(p1);
p1 = constant*arand.*brand.*crand.*drand./erand;
it's not clear p1
before if
statement.
note, "if p1 > 0
" means "if all(p1 > 0)
".
Comments
Post a Comment