C Library Functions  - var (3)

NAME

var(3f) - [M_datapac:STATISTICS] compute the sample variance of a vector of observations

CONTENTS

Synopsis
Description
Input Arguments
Output Arguments
Examples
Author
Maintainer
License
References

SYNOPSIS

SUBROUTINE VAR(X,N,Iwrite,Xvar)

       REAL(kind=wp),intent(in) :: X(:)
       INTEGER,intent(in) :: N
       INTEGER,intent(in) :: Iwrite
       REAL(kind=wp),intent(out) :: Xvar

DESCRIPTION

VAR(3f) computes the sample variance (with denominator N-1) of the data in the input vector X.

The sample variance = (the sum of the squared deviations about the sample mean)/(N-1).

Variance is the expectation of the squared deviation of a random variable from its population mean or sample mean. Variance is a measure of dispersion, meaning it is a measure of how far a set of numbers is spread out from their average value.

INPUT ARGUMENTS

X The vector of (unsorted or sorted) observations.
N The integer number of observations in the vector X.
IWRITE An integer flag code which (if set to 0) will suppress the printing of the sample variance as it is computed; or (if set to some integer value not equal to 0), like, say, 1) will cause the printing of the sample variance at the time it is computed.

OUTPUT ARGUMENTS

XVAR The value of the computed sample variance (with denominator N-1).

EXAMPLES

Sample program:

   program demo_var
   use M_datapac, only : var, label
   implicit none
   real,allocatable :: x(:)
   real :: Xvar
      call label(’var’)
      x = [46.0, 69.0, 32.0, 60.0, 52.0, 41.0]
      call VAR(X,size(x),1,Xvar)
      write(*,*)merge(’GOOD’,’BAD ’,Xvar == 177.2), Xvar
   end program demo_var

Results:

    The sample variance of the 6 observations is  0.17720000E+03
    GOOD   177.2000

AUTHOR

The original DATAPAC library was written by James Filliben of the Statistical Engineering Division, National Institute of Standards and Technology.

MAINTAINER

John Urban, 2022.05.31

LICENSE

CC0-1.0

REFERENCES

o Snedecor and Cochran, Statistical Methods, Edition 6, 1967, page 44.
o Dixon and Massey, Introduction to Statistical Analysis, Edition 2, 1957, page 38.
o Mood and Grable, ’Introduction to the Theory of Statistics, Edition 2, 1963, page 171.


Nemo Release 3.1 var (3) July 22, 2023
Generated by manServer 1.08 from 05fc934f-9854-49ea-afcc-bda907d63851 using man macros.