Previous Page Next Page Contents

stats::harmonic -- the harmonic mean

Introduction

stats::harmonic(data) returns the harmonic mean of the data.

Call(s)

stats::harmonic(x1, x2, ..)
stats::harmonic([x1, x2, ..])
stats::harmonic(s <, c>)

Parameters

x1, x2, .. - the statistical data: arithmetical expressions.
s - a sample of domain type stats::sample.
c - an integer representing a column index of the sample s. This column provides the data x1, x2 etc.

Returns

an arithmetical expression. FAIL is returned, if one of the data values is zero (the harmonic mean does not exist).

Related Functions

stats::a_quantil, stats::geometric, stats::mean, stats::median, stats::modal, stats::quadratic, stats::stdev, stats::variance

Details

Example 1

We calculate the harmonic mean of three values:

>> stats::harmonic(a, b, c)
   
                                     3
                                 ---------
                                 1   1   1
                                 - + - + -
                                 a   b   c
      

Alternatively, the data may be passed as a list:

>> stats::harmonic([2, 3, 5])
   
                                   90/31
      

Example 2

We create a sample:

>> stats::sample([[a1, b1, c1], [a2, b2, c2]])
   
                               a1  b1  c1
                               a2  b2  c2
      

The harmonic mean of the second column is:

>> stats::harmonic(%, 2)
   
                                     2
                                  -------
                                  1    1
                                  -- + --
                                  b1   b2
      

Example 3

We create a sample consisting of one string column and one non-string column:

>> stats::sample([["1996", 1242], ["1997", 1353], ["1998", 1142]])
   
                              "1996"  1242
                              "1997"  1353
                              "1998"  1142
      

We compute the harmonic mean of the second column. In this case this column does not have to be specified, since it is the only non-string column:

>> float(stats::harmonic(%))
   
                                1239.71654
      

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000