Running average/sum questions

For general discussion related FlowStone
Post Reply
Quentin
Posts: 37
Joined: Sat Jul 14, 2012 5:35 am

Running average/sum questions

Post by Quentin »

Hi, this is really basic but the answer eludes me - I want to make a module that creates a running average and a total sum- I have an integer value and a trigger for each time I want to collect a value to include in the sum and running average. I guess essentially I need to perform x=x+n each time the trigger goes.. Sorry if I am missing something obvious..
Thanks
Quentin
User avatar
nix
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: Running average/sum questions

Post by nix »

How's this?->
average&sum.fsm
(420 Bytes) Downloaded 1065 times

sum_average.png
sum_average.png (38.89 KiB) Viewed 14652 times

Hope it works for you 8D
Quentin
Posts: 37
Joined: Sat Jul 14, 2012 5:35 am

Re: Running average/sum questions

Post by Quentin »

Thanks for the example, my problem that I don't want to build a huge array, just want to accumulate the sum of the values over a long period of time, sorry I realized after I posted that I should have explained this detail. Thanks again for the response..
Quentin
User avatar
trogluddite
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: Running average/sum questions

Post by trogluddite »

Hi Quentin,
This example should do what you want without eating up unnecessary memory...
Running Average.fsm
(125.62 KiB) Downloaded 1079 times
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Quentin
Posts: 37
Joined: Sat Jul 14, 2012 5:35 am

Re: Running average/sum questions

Post by Quentin »

Thanks so much, that is exactly what I was in the process of trying to piece together in ruby- I am new to ruby so it's slow going for me- so your timing could not be better with that example..
Quentin
Post Reply