Skip to content
Prev 4536 / 29559 Next

calculate geometric mean of mass of points

On Wednesday 19 November 2008, Ashton Shortridge wrote:
Here is another solution, based on the definition of the geometric mean 
w/respect to logarithms. 

geom-mean = e^{ 1/n * sum{ln x} }


# only works for positive coordinates !!
x <- runif(n=100, min=1, max=100) ; y <- runif(n=100, min=1, max=100)

# plot points
plot(x,y)

# plot the arithmetic mean point
points(mean(x), mean(y), pch=16, col='red')

# plot the geometric mean point
points(exp(mean(log(x))), exp(mean(log(y))), pch=16, col='blue')

Dylan