Is there a way to incrementally calculate the parameters for a Gaussian distribution? The only parameters that are of interest are the mean and standard deviation, not the height (ie. normal distribution)
The problem is, I visit about 100 billion data points, of which I need to quickly calculate/update the distribution parameters, but I can not store all points in memory or visit all points for every estimation.
I'm looking for a way to calculate the distribution with only keeping a persistent state of size N(1) and the latest visited data point.
I can calculate the 'running mean' by this (assuming no numerical inaccuracies):
mean=0; mean[n+1] = mean[n] + (value - mean[n]) / (n+1) #or alternatively: (more accurate in my experiments, but also slower) mean[n+1] = (n * mean[n] + value) / (n+1)
but I don't know how to calculate the 'running deviation' (or variance for that matter)
I could build a histogram of values, but the problem is that the initial spread of the values is unknown and could span in the hundreds but could just as well span millions (depending on the specific dynamic system generating values). Furthermore, as the simulation goes on, the deviation typically increases monotonically, starting at 0.