addaptic

Reference Means

lz_gmean

The geometric mean of a list.

long lz_gmean( CLZNumber** values, long count, CLZNumber* targetNumber );

The nth root of the product of n values, correctly rounded. It takes an array and a count, as lz_amean does, and the target is required. A negative value is refused, kFailed, flagged not-a-number, and a nought makes the mean nought.

Examples

CallAnswerReturns
lz_gmean( { 2, 8 } )4kNoError
lz_gmean( { 1, 2, 3, 4 } )2.213363839400643184817580546880663297kNoError
lz_gmean( { 0, 5 } )0kNoError
lz_gmean( { −1, 4 } )not a numberkFailed

Each answer is what Addaptic printed for the call, at 36 places unless a setting is shown.

Returns

kNoError (0) when the answer is written. Otherwise an error code, with the answer flagged infinite or not-a-number; see Errors and flags.

See also

  • lz_amean The arithmetic mean of a list.
  • lz_hmean The harmonic mean of a list.
  • lz_agm The arithmetic-geometric mean of two numbers that are not negative.