krikr808/MD — Issue #7: We should change filtering method
Author: krikr808
Created: 2011-12-06 23:32:21+00:00
State: open

In order for the filtering method that uses nrinst should work well, nrinst has to be really large, and ideally span many "swings" (fluctuations forth and back) in the sampled properties. But in that case the number of measured points will be very few since we are only measuring each nrinst timestep, which is a very large number. If we keep this way of filtering, this will be a dilemma. The current low value of nrinst could also potentially be causing one of the "bugs" with the graphs, since the fluctuations are not filtered out as they should (especially in the T2 variable when measuring Cv).

I suggest that we instead use this variable (or even better, one with a good name) to determine the period between each sampling. Each property's samples are being stored in a vector, just like now (these sampled will be unfiltered). The samples are then filtered with some linear low-pass filtering method. This method should not reduce the number of data points.

If we stick to the filtering method we have now, which is a linear filter with an impulse response that is a [rectangular function](http://en.wikipedia.org/wiki/Rectangular_function), the amplitude characteristic of the filter will be a [scaled sinc function](http://www.wolframalpha.com/input/?i=fourier%28H%28x%2BT%29-H%28x-T%29%29). The amplitude characteristic will decrease as O(1 / f) for large frequencies f. This filter also results in quite few measured values since it only gets one filtered value for nrinst samples.

if we on the other hand use a filter with a two-sided exponentially decaying impulse response, we will get better low pass filter. That kind of filter will have an amplitude characteristic with [this shape](http://www.wolframalpha.com/input/?i=fourier%28e^%28-k*|x|%29%29), where k is the inverse of the cut-off frequency, which is much better suited for low-pass filtering. The amplitude characteristics decrease as O(1 / f2) for large frequencies f, which is much faster compared to the method we use now. Because the fluctuation can be considered to have high frequency, it is good that it decreases fast. This method will also result in more measured values, since we're actually converting *every* value we are filtering into a filtered valuie, and not just each nrinst value.