GEOMEAN Function
Calculates the geometric mean of an array, or calculate the geometric means over one dimension of an array.
Usage
result = GEOMEAN(arr)
Input Parameters
arr—A 1 or 2 dimensional array of non-negative, real, numeric values.
Returned Value
result—The geometric mean value of arr. If the Dimension keyword was set, the result is an array of geometric mean values over the specified dimension.
Keywords
Dimension—A scalar number defining the dimension of arr to compute geometric means over.
Geostd—(Output) Returns the associated geometric standard deviation(s).
Weights—An array of the same dimensions as arr specifying non-negative weights for values of arr. GEOMEAN then returns a weighted geometric average (and weighted standard deviation if Geostd was set).
Example
x = [[1.1, 1.2, .85], [.75, 1.5, 2.0]]
w = [[1.0, 2.0, 0.5], [1.0, 1.0, 1.0]]
 
PM, x, Title='The data...'
; PV-WAVE prints:
;   1.10000      0.750000
;   1.20000       1.50000
;  0.850000       2.00000
 
PM, w, Title='The weighting...'
; PV-WAVE prints:
;   1.00000       1.00000
;   2.00000       1.00000
;  0.500000       1.00000
 
; Calculate the geometric mean of x.
gm = GEOMEAN(x, Geostd=gsd, Weights=w)
PRINT, 'The geometric mean and standard deviation of x:'
PRINT, gm, gsd
; PV-WAVE prints:
;   1.20084       1.40720
 
; Calculate the geometric mean across the columns of x.
gm = GEOMEAN(x, Geostd=gsd, Weights=w, Dimension=0)
PRINT, 'Statistics for the first column of x:'
PRINT, gm(0), gsd(0)  ; Statistics for the first column of x.
; PV-WAVE prints:
;   1.11427       1.22362
PRINT, 'Statistics for the second column of x:'
PRINT, gm(1), gsd(1)  ; Statistics for the second column of x.
; PV-WAVE prints:
;   1.31037       1.65564
 
; Calculate the geometric mean across the rows of x.
; The result will be a length 3 vector.
;x = [[1.0, 1.2, .85], [1.0, 1.5, 2.0]]
 
gm = GEOMEAN(x, Geostd=gsd, Weights=w, Dimension=1) 
PRINT, 'The geometric mean across the rows of x:'
PRINT, gm
PRINT, 'The geometric standard deviation across the rows of x:'
PRINT, gsd
; PV-WAVE prints:
;   1.00000       1.00000