Exercise 43. A Simple Statistics Engine
This is a simple algorithm that I use for collecting summary statistics online, or without storing all of the samples. I use this in any software that needs to keep some statistics, such as mean, standard deviation, and sum, but can’t store all the samples needed. Instead, I can just store the rolling results of the calculations, which is only five numbers.
Rolling Standard Deviation and Mean
The first thing you need is a sequence of samples. This can be anything from the time it takes to complete a task to the number of times someone accesses something to star ratings on a Web site. It doesn’t really matter what it is, just so long as you have a stream of numbers and you want to know the following summary ...
Get Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.