Cumulative standard deviation: Difference between revisions

m
Line 3,574:
If the goal is to get a vector of running standard deviations, the simplest is to do it with cumsum:
 
<lang rrsplus>cumsd <- function(x) {
n <- seq_along(x)
sqrt(cumsum(x^2) / n - (cumsum(x) / n)^2)
Line 3,592:
The task requires an accumulator solution:
 
<lang rrsplus>accumsd <- function() {
n <- 0
m <- 0
1,336

edits