### R code from vignette source '/Users/dtenenba/dev/bioc_devel/IRanges//vignettes/RleTricks.Rnw'

cumsum(c(Rle(sum(window(x, 1, k))), window(x, k + 1, n) - window(x, 1, n - k))) / k
cumsum(c(Rle(sum((window(x, 1, k) - means[1])^2)),
(window(x, k + 1, n) - nextMean)^2)) / (k - 1)
nextMeanX <- window(meanX, 2, n - k + 1)
nextMeanY <- window(meanY, 2, n - k + 1)
cumsum(c(Rle(sum((window(x, 1, k) - meanX[1]) * (window(y, 1, k) - meanY[1]))),
(window(x, 1, n - k) - nextMeanX) * (window(y, 1, n - k) - nextMeanY) +
(window(x, k + 1, n) - nextMeanX) * (window(y, k + 1, n) - nextMeanY))) / (k - 1)
rollcovRle(x, y, k) / (rollsdRle(x, k) * rollsdRle(y, k))