tag:blogger.com,1999:blog-5822805028291837738.post6137376055990524294..comments2020-02-27T07:18:03.702-05:00Comments on Various Consequences: How to Speed Up OctaveJoshua Stultshttp://www.blogger.com/profile/03506970399027046387noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-5822805028291837738.post-35593865854905874112012-01-02T09:36:45.394-05:002012-01-02T09:36:45.394-05:00I got this request for help on speeding up a movin...I got this request for help on speeding up a moving average calculation by email recently.<br /><br />> The original problem is<br />> for j=2:length(data)<br />> a(j) = a(j-1) + alpha*(data(j)-a(j-1));<br />> endfor<br />> Now after creating A as a sparse matrix, given the original above,<br />> what is "b" in your equation "x = A\b"?<br />><br />The way I do it is to think of each iteration of the loop as an equation (see <a href="http://www.variousconsequences.com/2008/12/more-on-speeding-up-octave.html" rel="nofollow">this post</a>). <br /><br />Writing out your loop I get a (alpha - 1) on the sub-diagonal, and a 1 on the main diagonal. I get an alpha*d(j) on the right-hand side, so that's your b.Joshua Stultshttps://www.blogger.com/profile/03506970399027046387noreply@blogger.com