<HTML dir=ltr><HEAD>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7601.17998"></HEAD>
<BODY bgColor=#ffffff text=#000000>
<DIV dir=ltr id=idOWAReplyText51746>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Thanks Serge for your help,</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>Transforming a 3D array into a 2D allows to vectroize my problem in a simple way.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>I have noted the true definition of the variance... We did not talk about the same actually..</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>Stéphane</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>De:</B> users-bounces@lists.scilab.org de la part de Serge Steer<BR><B>Date:</B> mar. 12/02/2013 17:50<BR><B>À:</B> International users mailing list for Scilab.<BR><B>Objet :</B> Re: [Scilab-users] Vectorization<BR></FONT><BR></DIV>
<DIV>
<DIV class=moz-cite-prefix>You can try something like<BR>// CALCULATE VARIANCE OVER LAST N POINTS <BR><BR>Ni    =    100;<BR>Nj    =    10;<BR>Nk    =    10;<BR><BR>A     =    rand(Ni,Nj,Nk);    <BR>tic;<BR>A=matrix(A,Ni,-1);//transform A into a 2D array<BR>D1=zeros(Ni-N+1,Nj*Nk);<BR>for i=N:Ni, <BR>  D1(i-(N-1),:)=variance(A(i-(N-1):i,:),1);<BR>end<BR><BR>D1=matrix(D1,-1,Nj,Nk); //Transform D1 into a 3D array<BR>toc<BR><BR>Are you sure of your variance definition? For me if v is a vector the variance of v is computed by sqrt(sum( (v-mean(v))^2))<BR><BR>Serge Steer<BR>INRIA<BR>Le 12/02/2013 17:10, Stéphane Bécu a écrit :<BR></DIV>
<BLOCKQUOTE cite="" type="cite">
<DIV><FONT color=#000000 size=2 face=Arial>Hello,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>I have much difficulty to optimize my calculation. It consists of calculating the variance of a vector over last N elements . See the example in the attached file for a 3D matrix. With a PC under windows 7 and scilab 5.3, it needs 40 sec to calculate the variance for a 10*10*1000 matrix. This is too much long since I have much bigger files to work on.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>There must be a way to vectorize the problem but I do not see how ?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>Thanks in advance,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>Stéphane</FONT></DIV><BR>
<FIELDSET class=mimeAttachmentHeader></FIELDSET> <BR><PRE>_______________________________________________
users mailing list
<A class=moz-txt-link-abbreviated href="mailto:users@lists.scilab.org">users@lists.scilab.org</A>
<A class=moz-txt-link-freetext href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</A>
</PRE></BLOCKQUOTE><BR></DIV></BODY></HTML>