79463930

Date: 2025-02-24 14:57:04
Score: 0.5
Natty:
Report link

The advantage of using numpy is that you can specify an optional axis argument along which the mean should be calculated:

def geom_mean(arr, axis=None):
    return np.exp(np.mean(np.log(arr), axis=axis))

It uses the identity exp(arithmetic_mean(log(values))) = geometric_mean(values)

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: pas-calc