geometric-mean

Python : easy way to do geometric mean in python?

冷暖自知 提交于 2019-12-20 17:34:12
问题 I wonder is there any easy way to do geometric mean using python but without using python package. If there is not, is there any simple package to do geometric mean? 回答1: The formula of the gemetric mean is: So you can easily write an algorithm like: import numpy as np def geo_mean(iterable): a = np.array(iterable) return a. prod() **(1.0/len(a)) You do not have to use numpy for that, but it tends to perform operations on arrays faster than Python (since there is less "overhead" with casting)

Geometric Mean: is there a built-in?

无人久伴 提交于 2019-11-26 23:54:31
I tried to find a built-in for geometric mean but couldn't. (Obviously a built-in isn't going to save me any time while working in the shell, nor do I suspect there's any difference in accuracy; for scripts I try to use built-ins as often as possible, where the (cumulative) performance gain is often noticeable. In case there isn't one (which I doubt is the case) here's mine. gm_mean = function(a){prod(a)^(1/length(a))} Here is a vectorized, zero- and NA-tolerant function for calculating geometric mean in R. The verbose mean calculation involving length(x) is necessary for the cases where x

Geometric Mean: is there a built-in?

邮差的信 提交于 2019-11-26 09:16:40
问题 I tried to find a built-in for geometric mean but couldn\'t. (Obviously a built-in isn\'t going to save me any time while working in the shell, nor do I suspect there\'s any difference in accuracy; for scripts I try to use built-ins as often as possible, where the (cumulative) performance gain is often noticeable. In case there isn\'t one (which I doubt is the case) here\'s mine. gm_mean = function(a){prod(a)^(1/length(a))} 回答1: Here is a vectorized, zero- and NA-tolerant function for

Geometric Mean: is there a built-in?

瘦欲@ 提交于 2019-11-26 08:50:16
问题 I tried to find a built-in for geometric mean but couldn\'t. (Obviously a built-in isn\'t going to save me any time while working in the shell, nor do I suspect there\'s any difference in accuracy; for scripts I try to use built-ins as often as possible, where the (cumulative) performance gain is often noticeable. In case there isn\'t one (which I doubt is the case) here\'s mine. gm_mean = function(a){prod(a)^(1/length(a))} 回答1: Here is a vectorized, zero- and NA-tolerant function for