Dear All,
I have spent most of my time trying to figure out how to simulate the number of
breaks in a pipe using Monte Carlo simulation.
i have 20,000 individual pipes that i have to run, and for each pipe i have to
run 1000 times while checking some conditions and therefore, i have to use a
nested loop.
what i would like to have as a final result is a matrix table with with all the
individual pipe elements and the simulated runs
here is the loop that i tried to create
x=20000
y=matrix(x, z)
p=runif(1000)
for(j in 1:20000) {
for(i in 1:1000) {
k=1.15
l=exp((1/k)*(7.16-0.44+0.12-0.016))
z[i]=(log(1/p[i])*l)^k
if (z[i] <=684)
{
k1=0.504
l1=exp((1/k)*(8.01-1.5+0.35+0.45))
z1[i]=(log(1/p[i])*l1)^k1
if (z1[i] <=684)
{
k2=0.43
l2=exp((1/k2)*(9.55-2.45+0.40+0.65))
z2[i]=(log(1/p[i])*l2)^k2
p[i]=[i+1]
break()
}
}
}
x[ j ]=[ j+1 ]
}
the last column of the table, in addition to the simulated runs, i would like
to have the summary of the means (for z<=684) of individual row as this means
will give me the number of breaks.
i will really appreciate if anyone who can help me figure out how to go about
this. pardon me, I am new to R and programming.
Thank you in Advance,
Eliab
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]