Created
April 9, 2015 04:20
-
-
Save schmrlng/d9cdfeeb6a534f276159 to your computer and use it in GitHub Desktop.
O(n) functions for computing cumulative estimates of some basic statistics (useful e.g. for plotting how these estimates evolve).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cummean(x) = cumsum(x) ./ [1:length(x)] | |
cumvar(x, m = cummean(x)) = cumsum((1 - 1 ./ [1:length(x)]).*(x - [0, m[1:end-1]]).^2) ./ [1:length(x)] | |
cumcov(x, y, mx = cummean(x), my = cummean(y)) = cumsum((1 - 1 ./ [1:length(x)]).*(x - [0, mx[1:end-1]]).*(y - [0, my[1:end-1]])) ./ [1:length(x)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment