Documentation/Calc Functions/HARMEAN

    From The Document Foundation Wiki

    Function name:

    HARMEAN

    Category:

    Statistical Analysis

    Summary:

    Calculates the harmonic mean of a set of positive numbers. The harmonic mean of a set of numbers is obtained by calculating the reciprocal of each value, determining the average of these reciprocals, and then taking the reciprocal of that average.

    Syntax:

    HARMEAN(Number 1 [; Number 2 [; … [; Number 255]]])

    Returns:

    Returns a positive real number which is the harmonic mean of the supplied numbers.

    Arguments:

    Number 1, Number 2, … , Number 255 give the set of real numbers for which the geometric mean is to be calculated. Each argument may take one of the following forms:

    • A real number, or an expression that evaluates to a real number.
    • A reference to a single cell containing a real number.
    • A simple reference to a cell range containing real numbers.
    • The name of a named range, comprising cells containing real numbers.
    • The name of a database range, comprising cells containing real numbers.
    • An inline array of real numbers (for example, { 1.1; 2.2; 3.3; 4.4 }).

    Note that although HARMEAN can accept up to 255 arguments, each argument could specify a range of cells. This means that the number of real numbers processed could be many more than 255.

    The following conditions (including errors) may be encountered:

    • If any argument is a string in quotation marks, then HARMEAN reports a parameter list error (Err:504).
    • Text in cells and empty cells are ignored.
    • If there are no supplied numbers, then HARMEAN reports a #NUM! error.
    • If any supplied number is negative, then HARMEAN reports an invalid argument error (Err:502).
    • If only one value is supplied, then HARMEAN returns that value.

    Additional details:

    • The formula for calculating the harmonic mean ([math]\displaystyle{ \bar{x}_{harm} }[/math]) of a dataset [math]\displaystyle{ \left\{ {x_1, x_2, \cdot \cdot \cdot, x_{n-1}, x_n} \right\} }[/math] is:
    [math]\displaystyle{ \bar{x}_{harm}~=~ \frac{n}{\displaystyle \sum_{i=1}^{n} \left( \frac{1}{x_i}\right)} ~=~\frac{n}{\left(\frac{1}{x_1}\:+\:\frac{1}{x_2}\:+\: \cdot\cdot\cdot\:+\frac{1}{x_{n-1}}\:+\:\frac{1}{x_n} \right)} }[/math]
    To find the value of n, use the COUNT function.
    • For more information on the harmonic mean, visit Wikipedia's Harmonic mean page.

    Examples:

    Data for examples
    A B C D E
    1 1 2 3 4 5
    Formula Description Returns
    =HARMEAN(A1:E1) Calculate the harmonic mean of five values passed in a cell range. 2.18978102189781
    =HARMEAN(23.4; 34.5; 45.6; 56.7) Calculate the harmonic mean of four values passed as individual arguments. 35.9430830634942
    =HARMEAN({2; 4; 6; 8; 10; 12}) Calculate the harmonic mean of six values passed in an inline array. 4.89795918367347
    =HARMEAN(50; 110) Calculate the average speed in kph for a 100 km journey,

    assuming 50 km of the journey are driven in urban areas at 50 kph and the other 50 km are driven on motorways at 110 kph. The value returned can be checked by determining the total time taken for the journey, which is:

    [math]\displaystyle{ \frac{50}{50} + \frac{50}{110} = \frac{160}{110}\: }[/math]hours.

    To complete a journey of 100 km in this time implies an average speed of:

    [math]\displaystyle{ \frac{100}{\left (\frac{160}{110}\right )} = 68.75\: }[/math]kph.
    68.75

    Related LibreOffice functions:

    AVERAGE

    COUNT

    GEOMEAN

    ODF standard:

    Section 6.18.36, part 2

    Related (or similar) Excel functions:

    HARMEAN