C++Guns – RoboBlog

26.02.2015

rosettacode - Simple moving variance

Filed under: Allgemein — Tags: , — Thomas @ 11:02

As mentioned in my earlier post original C++ rosettacode sucks. Here is my example for a simple moving variance and standard deviation. One has to add only a few lines of code: in add() ... sum2 = sum2 - oldValue*oldValue + value*value; ... double var() const { return sum2/size - avg()*avg(); } double std() const […]

18.02.2015

rosettacode - Simple moving average

Filed under: Allgemein — Tags: , , — Thomas @ 12:02

http://rosettacode.org/wiki/Averages/Simple_moving_average#C.2B.2B The original rosetta C example shows the usage of variable function arguments. The C++ example shows how to implement a circular buffer. They are confusing and inefficient. My Version shows how to implement a simple moving average using modern c++ techniques. #include < iostream > #include < vector > class SMA { public: SMA(int […]

Powered by WordPress