Evaluating mean and std as simulations are added
Posted
by
Luca Cerone
on Programmers
See other posts from Programmers
or by Luca Cerone
Published on 2012-10-01T09:13:12Z
Indexed on
2012/10/01
9:49 UTC
Read the original article
Hit count: 360
memory
|simulation
I have simulations that evaluate a certain value X. I run the simulations several times and save the value of X in a vector V. When all the runs have finished I evaluate the mean and standard deviation for the vector V.
This approach works, but implies saving all the values for X. As my computer is quite old and with limited ram, I was wondering if there is a way to update the mean value M and the standard deviation S, knowing the value of X at the (n+1)-th run, and the values of M and S after n runs.
How can I update the mean value and the standard deviation as simulations are added to the set?
Please note that this is just a conceptual example, I don't save only one number X but thousands at each simulations, so I really have problems running a big number of runs if I have to keep all the past values into the memory.
© Programmers or respective owner