[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'math' (#rtl)

variance

Return variance of values

Declaration

Source position: math.pp line 477

function variance(

  const data: array of Single

):Float;

function variance(

  const data: PSingle;

  const N: Integer

):Float;

function variance(

  const data: array of Double

):Float;

function variance(

  const data: PDouble;

  const N: Integer

):Float;

function variance(

  const data: array of Extended

):Float;

function variance(

  const data: PExtended;

  const N: Integer

):Float;

Description

Variance returns the variance of the values in the data array. It returns zero if there is only one value.

The second form of the function accepts a pointer to an array of N values.

Errors

None.

See also

totalvariance

  

Return total varians of values

stddev

  

Return standard deviation of data

mean

  

Return mean value of array

Example

Program Example50;

{ Program to demonstrate the Variance function. }

Uses math;

Var
  I : 1..100;
  ExArray : Array[1..100] of Float;
  V : float;

begin
  Randomize;
  for I:=low(ExArray) to high(ExArray) do
    ExArray[i]:=(Random-Random)*100;
  V:=Variance(ExArray);
  Writeln('Variance     : ',V:8:4);
  V:=Variance(@ExArray[1],100);
  Writeln('Variance (b) : ',V:8:4);
end.

Documentation generated on: Mar 17 2017