Description Usage Arguments Value Note Author(s) References See Also Examples
Compute, join, or unjoin multivariate centered (co-) sums.
1 2 3 4 5 6 7 | cent_cosums(v, max_order = 2L, na_omit = FALSE)
cent_comoments(v, max_order = 2L, used_df = 0L, na_omit = FALSE)
join_cent_cosums(ret1, ret2)
unjoin_cent_cosums(ret3, ret2)
|
v |
an m by n matrix, each row an independent observation of some n variate variable. |
max_order |
the maximum order of cosum to compute. For now this can only be 2; in the future higher order cosums should be possible. |
na_omit |
a boolean; if |
used_df |
the number of degrees of freedom consumed, used in the denominator of the centered moments computation. These are subtracted from the number of observations. |
ret1 |
a multdimensional array as output by |
ret2 |
a multdimensional array as output by |
ret3 |
a multdimensional array as output by |
a multidimensional arry of dimension max_order
, each side of length
1+n. For the case currently implemented where max_order
must be 2, the
output is a symmetric matrix, where the element in the 1,1
position is the count of
complete) rows of v
, the 2:(n+1),1
column is the mean, and the
2:(n+1),2:(n+1)
is the co sums matrix, which is the covariance up to scaling
by the count. cent_comoments
performs this normalization for you.
The moment computations provided by fromo are numerically robust, but will often not provide the same results as the 'standard' implementations, due to differences in roundoff. We make every attempt to balance speed and robustness. User assumes all risk from using the fromo package.
Steven E. Pav shabbychef@gmail.com
Terriberry, T. "Computing Higher-Order Moments Online." 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. https://www.semanticscholar.org/paper/Numerically-stable-single-pass-parallel-statistics-Bennett-Grout/a83ed72a5ba86622d5eb6395299b46d51c901265
Cook, J. D. "Accurately computing running variance." http://www.johndcook.com/standard_deviation.html
Cook, J. D. "Comparing three methods of computing standard deviation." http://www.johndcook.com/blog/2008/09/26/comparing-three-methods-of-computing-standard-deviation
cent_sums
1 2 3 4 5 6 7 8 9 10 11 12 13 | set.seed(1234)
x1 <- matrix(rnorm(1e3*5,mean=1),ncol=5)
x2 <- matrix(rnorm(1e3*5,mean=1),ncol=5)
max_ord <- 2L
rs1 <- cent_cosums(x1,max_ord)
rs2 <- cent_cosums(x2,max_ord)
rs3 <- cent_cosums(rbind(x1,x2),max_ord)
rs3alt <- join_cent_cosums(rs1,rs2)
stopifnot(max(abs(rs3 - rs3alt)) < 1e-7)
rs1alt <- unjoin_cent_cosums(rs3,rs2)
rs2alt <- unjoin_cent_cosums(rs3,rs1)
stopifnot(max(abs(rs1 - rs1alt)) < 1e-7)
stopifnot(max(abs(rs2 - rs2alt)) < 1e-7)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.