home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / GMEAN.ICN < prev    next >
Text File  |  1991-07-13  |  692b  |  29 lines

  1. ############################################################################
  2. #
  3. #    Name:   gmean.icn
  4. #
  5. #    Title:  Compute geometric mean
  6. #
  7. #    Author: Gregg M. Townsend
  8. #
  9. #    Date:   November 10, 1990
  10. #
  11. ############################################################################
  12. #
  13. #     This procedure computes the geometric mean of an arbitrary number of
  14. #  values. It fails if there are no arguments or if any argument is zero.
  15. #
  16. ############################################################################
  17.  
  18. procedure gmean(L[])
  19.    local m
  20.  
  21.    m := 1.0
  22.    every m *:= !L
  23.    m := abs(m)
  24.    if m > 0.0 & *L > 0 then
  25.       return exp (log(m) / *L)
  26.    else
  27.       fail
  28. end
  29.