c# - Calculating RMS with overlapping windows -


I have a 1-dimensional float array, each computed with a single window length. Now say that

  RMS = {0, 0.01, 0.4, ...}  

Now the RMS for a larger window, Can be shown in the range of the original windows, as RMS of "participating" RMS from RMS [i] to RMS [i + len] May be. Here is the length of the big window divided by the length of the lane original window.

I want to create a rolling window. I want

  RMS from RMS [0] = 0 to lane ... rollingRMS [n] = lms to n + ln + n  

As calculated as efficiently as possible, I know that cracking is not very difficult, but has anyone prepared the code prepared for it?

Edit: I asked the sample code, so I think it would be nice to provide something below based on the answer to Pierce and written in C #. This is slightly different from my original question because I realized that it would be good to be similar to the original size of the resulting array and to be the window end on each element.

// RMS data to be analyzed float [] RMS = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // Resulting Rolling RMS Value Float [] RollingRMS = New Float [RMS.Long]; // window length int len ​​= 3; // Calculate: RollingRMS RMS array will mean each class from the root which will be / on each related sample. Input // for the first lane specimens will be treated as zero-pad (int i = 0; i & lt; RMS.Length; i ++) {if (i == 0) rolling RMS [i] = (Float) monastery scurr (RMS [i] * RMS [ii] / lane)); Other if rolling RMS [i] = (Float) Math SRT (RMS) * RMS [I] + Lane * (Rolling RMS [I-1] Rolling RMS [I-1]) / Lane; RMS RMS [I-1] * RMS [I] * RMS [I] - RMS [I-LAN] * RMS (Rolling RMS [I-1] * RMS [I] [I-LAN]) / LAN); }

I'm not sure that I've understood your problem correctly Give me a try

  a = [1,2,3,4,5,6,7,8,9,10] LAN = 3 squarefolding rms [0] = (A [0] ^ 2 + A [2] ^ 2 + A [2] ^ 2) / lan square offrolling rms [1] = (a [1] ^ 2 + a [2] ^ 2 + a [3] ^ 2) / lan   
  square offrolling rms [i] = rolling rms [i-1] * lan - a [ii]] ^ 2 + a [i + lan -1] ^ 2 rollingRMS [ii] = squafofofrollingRMS [i] ^ (1/2)  

Do this in this way, you are avoiding the overlap window to avoid it again.

Edit:

You can save some division and multiplication handle by moving LEN to the left side of the equations. It can move too much because usually splitting is relatively slow.

  LEN_by_SquareOfRollingRMS [0] = (a [0] ^ 2 + a [1] ^ 2 + a [2] ^ 2) LEN_by_SquareOfRollingRMS [i] = LEN_by_RollingRMS [i-1] - One [I-1] ^ 2 + one [i + lan-1] ^ 2  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -