On Sat, 15 Aug 2020 at 20:56, Isaac Marino Bavaresco <
[hidden email]> wrote: > Em 14 de agosto de 2020 22:04:36 BRT, RussellMc <[hidden email]> > escreveu: > > >> Latest/N + Sum x (N-1)/N > > Does N grow indefinitely? > If yes, the new values will have less and less influence as time goes by. > If not, there will be a steady increase in the final result. > Sorry - it didn't occur to me that that was ambiguous. Note that this was an algorithm that I said was not as good as retaining K samples and averaging them. N is a selected factor that controls how much effect the latest sample has compared to all prior samples. Define "AVAL" as the averaged value Initially, set AVAL = 1st sample Set N to say 4. This means that from now on new samples will account for 1/4 of the new value of AVAL and the old value will account for 3/4 of the value of AVAL. so AVAL = 1/4 x latest sample + 3/4 x AVAL If N was 10 it would be 1/10x sample + 9/10 x AVAL. This is not a marvellous method but has the advantage of not requiring retaining any prior sample values and of the effects of past samples diminishing relatively rapidly. Example: N=4 Sequence 5 5 5 5 5 20 20 20 20 20 Output 5 5 5 5 5 8.75 11.6 13.7 15.3 16.5 ... For a single step function AVAL never reached the new value! ______________________________ Better: If you retain say the last 4 and average them with the same input you get 5 5 5 5 5 8.75 12.5 16.25 20 20 ... For a single outlier eg 5 5 5 5 5 20 5 5 5 5 5 5 You'd get 5 5 5 5 5 8.75 8.75 8.75 8.75 5 5 5 ie the outlier has an effect for N samples. R > > -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist |
On Sun, 16 Aug 2020, RussellMc wrote: > On Sat, 15 Aug 2020 at 20:56, Isaac Marino Bavaresco < > [hidden email]> wrote: > >> Em 14 de agosto de 2020 22:04:36 BRT, RussellMc <[hidden email]> >> escreveu: >> > > >>>> Latest/N + Sum x (N-1)/N >> >> Does N grow indefinitely? >> If yes, the new values will have less and less influence as time goes by. >> If not, there will be a steady increase in the final result. >> > > Sorry - it didn't occur to me that that was ambiguous. > Note that this was an algorithm that I said was not as good as retaining K > samples and averaging them. > > > N is a selected factor that controls how much effect the latest sample has > compared to all prior samples. > > Define "AVAL" as the averaged value > Initially, set AVAL = 1st sample > > Set N to say 4. This means that from now on new samples will account for > 1/4 of the new value of AVAL and the old value will account for 3/4 of the > value of AVAL. > > so AVAL = 1/4 x latest sample + 3/4 x AVAL > > If N was 10 it would be 1/10x sample + 9/10 x AVAL. > > This is not a marvellous method but has the advantage of not requiring > retaining any prior sample values and of the effects of past samples > diminishing relatively rapidly. > > Example: > N=4 > Sequence 5 5 5 5 5 20 20 20 20 20 > Output 5 5 5 5 5 8.75 11.6 13.7 15.3 16.5 ... > > For a single step function AVAL never reached the new value! > > ______________________________ > Better: > > If you retain say the last 4 and average them with the same input you get > 5 5 5 5 5 8.75 12.5 16.25 20 20 ... > > For a single outlier eg 5 5 5 5 5 20 5 5 5 5 5 5 > You'd get 5 5 5 5 5 8.75 8.75 8.75 8.75 5 5 5 > > ie the outlier has an effect for N samples. > > > R Hi Russell, I've had problems (long long ago) with: Latest/N + Sum x (N-1)/N (actually (Latest + Sum x (N-1))/N, but same thing) I've just done a simulation and a blip can cause an error much futher down the line that expected. Consider a constant reading of 1 and a window of 10. The average after everything has settled down is 1 as expected. Now introduce a reading of 1023 (being 2^10-1). After 44 samples (still of 1) the average has slowly come down but is still at 2. I don't know about the average of averages, I haven't investigated that. Friendly Regards Sergio -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist |
>
This post assumed a life that I did not intend :-).
> > Hi Russell, > > I've had problems (long long ago) with: > .. (actually (Latest + Sum x (N-1))/N, but same thing) > > I've just done a simulation and a blip can cause an error much futher down > the line that expected. Consider a constant reading of 1 and a window of > 10. The average after everything has settled down is 1 as expected. Now > introduce a reading of 1023 (being 2^10-1). After 44 samples (still of 1) > the average has slowly come down but is still at 2. > > Yes. I originally said ~~= that keeping N values in a FIFO and averaging them (so you can completely throw away samples after N cycles) was superior to the method discussed above. I've used both (lonnnnnnnnnnnnnng ago) and (again) the retain-N -samples method is superior. There are of course methods tricks" for dealing with outliers beyond acceptable limits, but, not using the method is even better. Russell -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist |
Free forum by Nabble | Edit this page |