Questions tagged [geometric-mean]

A mean that calculates the n-th root of the product of the numbers.

34 questions
119
votes
9 answers

Geometric Mean: is there a built-in?

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…
doug
  • 69,080
  • 24
  • 165
  • 199
44
votes
8 answers

Python : easy way to do geometric mean in python?

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?
user6922072
5
votes
4 answers

Resolving Zeros in Product of items in list

Given that we can easily convert between product of items in list with sum of logarithm of items in list if there are no 0 in the list, e.g: >>> from operator import mul >>> pn = [0.4, 0.3, 0.2, 0.1] >>> math.pow(reduce(mul, pn, 1),…
alvas
  • 115,346
  • 109
  • 446
  • 738
2
votes
1 answer

Standardize name in row and calculate the geometric mean based on similar row in R

I have a data table where I want to standardize the name in "Sex" and calculate the geometric mean based on each Group (as in x, y and z in the table). Would appreciate your help. Below are the data.table. library(data.table) dt <- data.table(Group…
Twinstan
  • 23
  • 3
2
votes
1 answer

MATLAB: cumulative geometric mean

I have a 2x3 matrix m = [1.1, 2.0, 0.5 ; 0.9, 1.5, 1.1];. I need to compute a cumulative geometric mean along the second dimension, i.e. the resulting matrix results must also have the same dimension (2x3). It's basically comparable to using cumprod…
Andi
  • 3,196
  • 2
  • 24
  • 44
1
vote
2 answers

Calculate geometric mean by ID across entire long data frame in R

In R, I am trying to calculate the geometric mean (exp(mean(log(x, na.rm=T))) across all columns in a data frame by participant ID. The data frame is in long format. Below is a comparable code that I have so far... it isn't working. I have also…
ehepikait
  • 13
  • 3
1
vote
1 answer

Geometric mean in SAS for each column of a data set

Suppose I have the following SAS data set data have; input id$ x1 x2 x3; datalines; 1 10 5 15 2 15 10 7 3 12 10 9 4 14 15 10 ; run; I would like to calculate the geometric mean, geometric coefficient of variation (formula is 100*(exp(ASD^2)-1)^0.5…
Uddin
  • 754
  • 5
  • 18
1
vote
1 answer

DESEQ2: varianceStabilizingTransformation Error: every gene contains at least one zero, cannot compute log geometric means

I have a data-set comprising of an OTU table, where rows = samples and columns = OTUs, like this: Otus <- data.frame(OTU_1 = c(0, 0, 1), OTU_2 = c(12, 0, 5), OTU_3 = c(0, 5, 3), row.names = c("S_1", "S_2", "S_3")) I moved it from phyloseq over to…
Purrsia
  • 712
  • 5
  • 18
1
vote
1 answer

Can I calculate the geometric mean with django annotation?

Is there a way to use it like Foo.objects.annotate(geometric_mean=GeometricMean('bars__value')) or Foo.objects.annotate(geometric_mean=Power(Prod('bars__value'), Count('bars'))
SeokJun Yeom
  • 401
  • 1
  • 4
  • 9
1
vote
3 answers

Divide value in each cell by the geometric mean of a specific row across columns and log-transform it

I would like to devide value in each cell by the geometric mean of a specific row across columns and log-transforme it (natural logarithm). df1 col1 col2 col3 row1 1 777 6 row2 136 1 665 row3 0 100 97 result df_new …
giegie
  • 463
  • 4
  • 11
1
vote
0 answers

Calculation of Geometric Mean of Data that includes NAs

EDIT: The problem was not within the geoMean function, but with a wrong use of aggregate(), as explained in the comments I am trying to calculate the geometric mean of multiple measurements for several different species, which includes NAs. An…
1
vote
1 answer

Calculating geometric mean every 10 min using dplyr or aggregte function

I am trying to calculate geometric mean of a column every 10 min. My sample data is.. TimeDate diam ratio 2016-05-11 8:25 134.491 1.83074 2016-05-11 8:25 117.777 1.34712 2016-05-11 8:25 104.27 0.927635 2016-05-11 8:25 204.085…
user2928318
  • 549
  • 3
  • 7
  • 20
1
vote
1 answer

Geometric mean filter with opencv

I want to apply a geometric mean filter on an image in opencv (python). Is there a builtin function or should I implement the filter myself? What is the most efficient way to implement a nonlinear filter in opencv?
Navid777
  • 3,591
  • 8
  • 41
  • 69
1
vote
1 answer

how to calculate geomatic average value with nans?

I would like to calculate the geometric mean of some data (including NaN), how can I do it? I know how to calculate the mean value with NaNs, we can use the following code: import numpy as np M = np.nanmean(data, axis=2). So how to do it with…
ERIC
  • 185
  • 1
  • 2
  • 10
1
vote
1 answer

calculating weighted geometric mean of a large list of numbers

I am trying to calculate a weighted geometric mean of a large list of number (about 115k numbers). Each number has a weight value of either 1, 2, or 3 assigned. There seem to be a ton of ways to calculate geometric mean ( non-weighted ), and one…
1
2 3