[Scilab-users] vector operation replacing for loop

Heinz Nabielek heinznabielek at me.com
Thu Nov 1 09:27:11 CET 2018


Sorry, Scilab friends, I am still not fluid with vector operations.
Can someone rewrite the for loop for me into something much more efficient?

n=1000;
Z=grand(1,n,'nor',0,1);
r=0.9;
V=Z;
for i=2:n;
	V(i)=r*V(i-1)+sqrt(1-r^2)*Z(i);
end;

The transformation generates an autocorrelated (here rho=0.9) normal distribution V from an uncorrelated normal distribution Z and eventually I will need it for very much larger n values....

Heinz


More information about the users mailing list