<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <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="mid:E9DEEAB2FB6E5A49B6F9FE70D0B8AF301CC785@SRVMAYA.maya.local"
      type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <meta name="GENERATOR" content="MSHTML 8.00.7601.17998">
      <div><font color="#000000" face="Arial" size="2">Hello,</font></div>
      <div> </div>
      <div><font face="Arial" size="2">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 face="Arial" size="2">There must be a way to vectorize
          the problem but I do not see how ?</font></div>
      <div> </div>
      <div><font face="Arial" size="2">Thanks in advance,</font></div>
      <div> </div>
      <div><font face="Arial" size="2">Stéphane</font></div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
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>
  </body>
</html>