The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals of the input values. Common uses include computing the mean of ratios, for instance the average P/E ratio in a portfolio. Also it is the correct mean for averaging speeds weighted for distance.
harmonic_mean(x, weights = NULL, na.rm = c(TRUE, FALSE))
A vector of values to take the harmonic mean for
Optional vector of weights.
remove NAs (default = TRUE).
Harmonic mean of x
Other Miscellaneous Stats Functions:
# Harmonic means are suitable for ratios tmp = c(33/1, 23/1) harmonic_mean(tmp) geometric_mean(tmp) mean(tmp) # Example with weights harmonic_mean(c(33/1, 23/1), weights= c(.2, .8)) # If Jack travels outbound at 1 mph, and returns at 10 miles an hour, what is his average speed? harmonic_mean(c(1,10)) # 1.81 mph
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.