Displaying 1 result from an estimated 1 matches for "simpd".
Did you mean:
simd
2011 Feb 17
1
How to speed up a for() loop
...and 30 seconds.
Because of the size of Nsim and N, simulating a multivariate normal
(instead of simulating Nsim times a vector of N normal distributions)
would require too much memory space.
Many thanks for your kind help,
Simona
N=3000
PD=runif(N,0,1)
cutoff.=qnorm(PD)
rho.=0.1
Nsim=100000
simPD.vec=0*(1:Nsim)
systemic = rnorm(Nsim,0,1);
for (i in 1:Nsim)
{
R.vec=sqrt(rho.)*systemic[i]+sqrt(1-rho.)*rnorm(N,0,1)
simPD.vec[i]=length(R.vec[R.vec<cutoff.])
}
-------------- next part --------------
Visit our website at http://www.ubs.com
This message contains confidential information...