Skip to contents

A function to return the cumulative harmonic mean of a vector.

Usage

chmean(.x)

Arguments

.x

A numeric vector

Value

A numeric vector

Details

A function to return the cumulative harmonic mean of a vector. 1 / (cumsum(1 / .x))

Author

Steven P. Sanderson II, MPH

Examples

x <- mtcars$mpg

chmean(x)
#>  [1] 21.0000000 10.5000000  7.1891892  5.3813575  4.1788087  3.3949947
#>  [7]  2.7436247  2.4663044  2.2255626  1.9943841  1.7934398  1.6166494
#> [13]  1.4784877  1.3474251  1.1928760  1.0701322  0.9975150  0.9677213
#> [19]  0.9378663  0.9126181  0.8754572  0.8286539  0.7858140  0.7419753
#> [25]  0.7143688  0.6961523  0.6779989  0.6632076  0.6364908  0.6165699
#> [31]  0.5922267  0.5762786