Unit 'Math' Package
[Overview][Constants][Types][Classes][Procedures and functions][Index] [#rtl]

MeanAndStdDev

Return mean and standard deviation of array.

Declaration

Source position: math.pp line 732

procedure MeanAndStdDev(

  const data: array of Single;

  var mean: Float;

  var stddev: Float

);

procedure MeanAndStdDev(

  const data: PSingle;

  const N: LongInt;

  var mean: Float;

  var stddev: Float

);

procedure MeanAndStdDev(

  const data: array of Double;

  var mean: Float;

  var stddev: Float

);

procedure MeanAndStdDev(

  const data: PDouble;

  const N: LongInt;

  var mean: Float;

  var stddev: Float

);

procedure MeanAndStdDev(

  const data: array of Extended;

  var mean: Float;

  var stddev: Float

);

procedure MeanAndStdDev(

  const data: PExtended;

  const N: LongInt;

  var mean: Float;

  var stddev: Float

);

Description

meanandstddev calculates the mean and standard deviation of data and returns the result in mean and stddev, respectively. Stddev is zero if there is only one value. The second form accepts a pointer to an array of N values.

Errors

None.

See also

mean

  

Return mean value of array.

sum

  

Return sum of values.

sumofsquares

  

Return sum of squares of values.

momentskewkurtosis

  

Return 4 first moments of distribution.

Example

Program Example28;

{ Program to demonstrate the Meanandstddev function. }
{ @ should return typed pointer }
{$T+}

Uses math;

Type
  TExArray = Array[1..100] of Extended;

Var
  I : Integer;
  ExArray : TExArray;
  Mean,stddev : Extended;

begin
  Randomize;
  or:=low(ExArray) to high(ExArray) do
    ExArray[i]:=(Random-Random)*100;
  MeanAndStdDev(ExArray,Mean,StdDev);
  Writeln('Mean       : ',Mean:8:4);
  Writeln('StdDev     : ',StdDev:8:4);
  MeanAndStdDev(@ExArray[1],100,Mean,StdDev);
  Writeln('Mean   (b) : ',Mean:8:4);
  Writeln('StdDev (b) : ',StdDev:8:4);
end.

Documentation generated on: Oct 27 2024