variance.f
上传用户:szhypcb168
上传日期:2007-01-06
资源大小:2187k
文件大小:1k
- c==========================================================================
- c
- c ROUTINE
- c variance
- c
- c FUNCTION
- c
- c calculates variance of the input array
- c
- c SYNOPSIS
- c subroutine variance(arr,no,var,avg)
- c
- c formal
- c
- c data I/O
- c name type type function
- c -------------------------------------------------------------------
- c arr real i input data array
- c no int i number of elements in array
- c var real o variance
- c avg real o average
- c
- c==========================================================================
- c
- c DESCRIPTION
- c
- c
- c**************************************************************************
- c
- subroutine variance(arr,no,var,avg)
- c
- implicit undefined(a-z)
- c
- integer no
- real arr(no),var
- integer i
- real sum,sum2,avg
- c
- sum=0.
- do 10 i=1,no
- sum=sum+arr(i)
- 10 continue
- avg=sum/float(no)
- sum2=0.
- do 20 i=1,no
- sum2=sum2+(avg-arr(i))*(avg-arr(i))
- 20 continue
- var=sum2/float(no-1)
- return
- end