Re: Moving average smoothing of curves in graphs



Le jeudi 09 février 2006 à 13:35 -0500, Morten Welinder a écrit : 
Original data: f(x_i) = y_i

            sum_i (f(x_i) * w_i(x))
m(x) = ---------------------------                                     (*)
                 sum_i w_i(x)

             /       0                       , if x_i > x
w_i(x) = {
             \       2^((x_i-x)/h)       , if x_i <= x

The "0" part ensures that as you draw the graph left-to-right, only points
to the left of where you are affect m(x).

Notice that for d>=0:

    w_i(x+d) = 2^(-d/h) * w_i(x)

which makes it easy to compute (*) because it stays constant between
the x_i's and you can easily compute the new nominator and denominator
from the old ones and the new data point.

OK, I see, it is quite easy to implement. Just two more questions:
- should I use the same x_i values when evaluating the smoothed ones (I
guess the answer is yes).
- how should I compute a default value for h ((last_x - first_x) / 10 ?)

Otherwise, the standard moving average works here. I'll make a patch
when I'll be back home, so that we can discuss a few points such as the
name of the new plugin (I use plugins/smoothing, but I'm not really
satisfied with that, although this is quite minor) and what I should do
with invalid data, at the moment, the smoothed curve is interrupted, but
it is possible to add an option to just skip the invalid data as we did
in regression curves.
I clearly separated smoothing from regression in the user interface, in
contrast from what other spreadsheets do. I suspect that some will not
agree with me.

While I'm there, I have a problem with the gaussian regression.
Regression curves use Bezier splines with 100 values at the moment. When
the gaussian peak is narrow, compared to the whole chart, the result is
quite weird. I'll have to find some means to have more points around the
peak than elsewhere. Ideas and comments are welcome ;-)

Cheers,
Jean




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]