geometric mean
gm = geomean(X) GM = geomean(X, orien) // orien: 'r'|1|'c'|2..ndims(X)
Vector, matrix or hypermatrix of real or complex numbers.
Dimension accross which the geometric average is computed. The value must be among 'r', 1, 'c', 2, .. ndims(X). Values 'r' (rows) and 1 are equivalent, as 'c' (columns) and 2 are.
Scalar number: the geometric mean gm = prod(X)^(1/N), where N = length(X) is the number of components in X.
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,:))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
|
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.
--> 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.
Wonacott, T.H. & Wonacott, R.J.; Introductory Statistics, fifth edition, J.Wiley & Sons, 1990.