Learn R Programming

fromo (version 0.2.5)

join_cent_sums: Join and unjoin centered sums.

Description

Join, or unjoin centered sums.

Usage

join_cent_sums(ret1, ret2)

unjoin_cent_sums(ret3, ret2)

Value

a vector the same size as the input consisting of the adjusted version of the input. When there are not sufficient (non-nan) elements for the computation, NaN are returned.

Arguments

ret1

an \(ord+1\) vector as output by cent_sums consisting of the count, the mean, then the k through ordth centered sum of some observations.

ret2

an \(ord+1\) vector as output by cent_sums consisting of the count, the mean, then the k through ordth centered sum of some observations.

ret3

an \(ord+1\) vector as output by cent_sums consisting of the count, the mean, then the k through ordth centered sum of some observations.

Author

Steven E. Pav [email protected]

References

Terriberry, T. "Computing Higher-Order Moments Online." https://web.archive.org/web/20140423031833/http://people.xiph.org/~tterribe/notes/homs.html

J. Bennett, et. al., "Numerically Stable, Single-Pass, Parallel Statistics Algorithms," Proceedings of IEEE International Conference on Cluster Computing, 2009. tools:::Rd_expr_doi("10.1109/CLUSTR.2009.5289161")

Cook, J. D. "Accurately computing running variance." https://www.johndcook.com/standard_deviation/

Cook, J. D. "Comparing three methods of computing standard deviation." https://www.johndcook.com/blog/2008/09/26/comparing-three-methods-of-computing-standard-deviation/

Examples

Run this code

 set.seed(1234)
 x1 <- rnorm(1e3,mean=1)
 x2 <- rnorm(1e3,mean=1)
 max_ord <- 6L
 rs1 <- cent_sums(x1,max_ord)
 rs2 <- cent_sums(x2,max_ord)
 rs3 <- cent_sums(c(x1,x2),max_ord)
 rs3alt <- join_cent_sums(rs1,rs2)
 stopifnot(max(abs(rs3 - rs3alt)) < 1e-7)
 rs1alt <- unjoin_cent_sums(rs3,rs2)
 rs2alt <- unjoin_cent_sums(rs3,rs1)
 stopifnot(max(abs(rs1 - rs1alt)) < 1e-7)
 stopifnot(max(abs(rs2 - rs2alt)) < 1e-7)

Run the code above in your browser using DataLab