[UP]


Manual Reference Pages  - stddev (3)

NAME

stddev(3f) - [M_math:statistics] given a real vector and the vector average calculate the standard deviation

CONTENTS

Syntax
Description
Options
Returns
Example
Author
Reference

SYNTAX

function stddev(vector,n,avg)

    integer,intent(in) :: n
    real,intent(in)    :: vector(n)
    real,intent(in)    :: avg
    real               :: stddev

DESCRIPTION

Clearly the average gives one number around which the n observations tend to cluster. And the standard deviation gives a measure of how the n observations vary or spread about this average. The square of the standard deviation is called the variance. If we consider a unit mass at each point x(i) , then the variance is equivalent to a moment of inertia about an axis through x(avg). It is readily seen that for a fixed value of x(avg), greater spreads from the average will produce larger values of the standard deviation s. The average and the standard deviation can be used jointly to summarize where the observations are concentrated. Tchebysheff’s theorem states :

    A fraction of at least 1 - (1/k**2) of the observations lie
    within k standard deviations of the average. The theorem
    guarantees lower bounds on the percentage of observations
    within k standard deviations of the average.

OPTIONS

n the size of the input vector
vector(n)
  the input vector
avg the average of the input vector

RETURNS

stddev the standard deviation of the vector

EXAMPLE

example:

    program demo_stddev
    use M_math, only : stddev
    implicit none
    integer :: i
    real,parameter :: vals(*)=[(i*1.0,i=0,100)]
       !!write(*,*)vals
       write(*,*)size(vals)
       write(*,*)sum(vals)/size(vals)
       write(*,*)stddev(vals,size(vals),sum(vals)/size(vals))
    end program demo_stddev

output:

         101
50.0000000 29.3001709

AUTHOR

1994 John S. Urban

REFERENCE

From Mark’s Handbook, page 17-19, 8th edition


stddev (3) October 17, 2020
Generated by manServer 1.08 from f5644b7b-dade-4eb0-b6ff-a2fe4f93d6f6 using man macros.