Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2024.1.0 - Português


geomean

geometric mean

Syntax

gm = geomean(X)
GM = geomean(X, orien)

Arguments

X

Vector, matrix or hypermatrix of real or complex numbers.

orien

Dimension accross which the geometric average is computed. The value must be among '*' (default value), 'r', 1, 'c', 2, .. ndims(X). Values 'r' (rows) and 1 are equivalent, as 'c' (columns) and 2 are.

gm

Scalar number: the geometric mean gm = prod(X)^(1/N), where N = length(X) is the number of components in X.

GM

Vector, matrix or hypermatrix of numbers. s = size(GM) is equal to size(X), except that s(orien) is set to 1 (due to the projected application of geomean() over components along the orien dimension).

If X is a matrix, we have:

  • GM = geomean(X,1) => GM(1,j) = geomean(X(:,j))
  • GM = geomean(X,2) => GM(i,1) = geomean(X(i,:))

Description

geomean(X,..) computes the geometric mean of values stored in X.

If X stores only positive or null values, gm or GM are real. Otherwise they are most often complex.

If X is sparse-encoded, then
  • it is reencoded in full format before being processed.
  • gm is always full-encoded.
  • GM is sparse-encoded as well.

Examples

geomean(1:10) // Returns factorial(10)^(1/10) = 4.5287286881167648

// Projected geomean:
// -----------------
m = grand(4,5, "uin", 1, 100);
m(3,2) = 0; m(2,4) = %inf; m(4,5) =  %nan
geomean(m, "r")
geomean(m, 2)
h = grand(3,5,2, "uin",1,100)
geomean(h,3)
--> m = grand(4,5, "uin", 1, 100);
--> m(3,2) = 0; m(2,4) = %inf; m(4,5) =  %nan
 m  =
   13.   5.    99.   41.   20.
   3.    92.   4.    Inf   5.
   35.   0.    36.   40.   98.
   86.   86.   66.   21.   Nan

--> geomean(m, "r")
 ans  =
   18.510058   0.   31.14479   Inf   Nan

--> geomean(m, 2)
 ans  =
   22.104082
   Inf
   0.
   Nan

--> h = grand(3,5,2, "uin",1,100)
 h  =
(:,:,1)
   10.   40.   37.   72.   30.
   10.   47.   54.   13.   19.
   44.   27.   61.   10.   27.
(:,:,2)
   96.   88.   7.    98.   35.
   54.   29.   96.   77.   8.
   94.   45.   21.   46.   3.

--> geomean(h,3)
 ans  =
   16.522712   43.150898   23.2379     36.91883    72.
   14.142136   13.747727   64.311741   34.85685    35.79106
   12.247449   30.983867   59.329588   16.093477   84.

// APPLICATION: Average growing rate
// ---------------------------------
// During 8 years, we measure the diameter D(i=1:8) of the trunc of a tree.
D = [10 14 18 26 33 42 51 70];          // in mm

// The growing rate gr(i) for year #i+1 wrt year #i is, in %:
gr = (D(2:$)./D(1:$-1) - 1)*100

// The average yearly growing rate is then, in %:
mgr = (geomean(1+gr/100)-1)*100

// If this tree had a constant growing rate, its diameter would have been:
D(1)*(1+mgr/100)^(0:7)
--> gr = (D(2:$)./D(1:$-1) - 1)*100
 gr  =
   40.   28.57   44.44   26.92   27.27   21.43   37.25

--> mgr = (geomean(1+gr/100)-1)*100
 mgr  =
   32.05

--> D(1)*(1+mgr/100)^(0:7)
 ans  =
   10.   13.2   17.44   23.02   30.4   40.15   53.01   70.

See also

  • prod — produto
  • harmean — harmonic mean : inverse of the inverses average (without zeros)

Bibliography

Wonacott, T.H. & Wonacott, R.J.; Introductory Statistics, fifth edition, J.Wiley & Sons, 1990.

Report an issue
<< center Mean Central Tendency harmean >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Jun 17 17:53:24 CEST 2024