Previous Page Next Page Contents

stats::variance -- the variance

Introduction

stats::variance(data) returns the variance of the data.

Call(s)

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

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.

Options

Sample - with this option the given data are regarded as a ``sample'', not a as a full population.

Returns

an arithmetical expression.

Related Functions

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

Details

Example 1

We calculate the variance of three values:

>> stats::variance(2, 3, 5)
   
                                   14/9
      

Alternatively, the data may be passed as a list:

>> stats::variance([2, 3, 5])
   
                                   14/9
      

Example 2

We create a sample:

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

The variance of the second column is:

>> expand(stats::variance(%, 2))
                               2             2
                             b1    b1 b2   b2
                             --- - ----- + ---
                              4      2      4

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 variance 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::variance(%))
   
                                7426.888889
      

We repeat the computation with the option Sample:

>> float(stats::variance(%2, Sample))
   
                                11140.33333
      

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000