Standard deviation of particular location and of area
Charles Seman
Charles.Seman at NOAA.GOV
Tue Sep 15 14:28:44 EDT 2009
Raj,
here's some documentation from a script used to calculate standard
deviation:
* From statistics (reference: "Statistical Concepts and Methods"
* by Bhattacharyya and Johnson (1977)), the sample variance s**2
* for a set of "N" observations of a variable "xi" (x1,...,xN)
* is defined as:
*
* s**2 = [(x1-xbar)**2 + (x2-xbar)**2 + (x3-xbar)**2 +....
* + (xN-xbar)**2 ]/(N-1) , (from page 34)
*
* where the sample mean = xbar = (x1+x2+x3+...+xN)/N , (from page 27)
*
* Note, the sample variance sums over "N" observations, and divides the
* sum by "N-1"...
*
* The sample standard deviation is defined as the square root of the
* sample variance (from page 35):
*
* s = sqrt(s**2)
perhaps you could try (please check for mistakes)
...same as in your email, then
sg = 0
tt = it
while(tt<='et')
'set t 'tt
...define whu at t = "tt"
sg = sg + pow((avg-whu),2)
endwhile
dt = et-it+1
sv = sg/(dt-1) * sample variance
'd sqrt(sv)'
std = subwrd(result,4)
say 'STD DEV = ',std
Hope this helps,
Chuck
Raj Kumar Sharma wrote:
> Hi, I have file containing global values of variable for whole year. I
> would like to compute Average & Standard Deviation for Particular
> Location and also for defined area.
> I had written script to compute Std Dev for a particular location,
> however it is showing error. It will be great if someone can help.
>
> Raj
>
> 'reinit'
> 'set display color white'
> clear
> 'set gxout shaded'
> 'open pqfull.ctl'
> ln = 60
> lt = -10
> it = 1
> et = 5
>
> 'set lon 'ln
> 'set lat 'lt
>
> 'd ave(whu,t='it',t='et')'
> lin=sublin(result,2)
> avg = subwrd(lin,4)
> say 'AAAA 'avg
> while(t<'et')
> sg = sg + (avg-whu)
> df = pow(sg,2)
> endwhile
> dt = et-it+1
> std = df/dt
> 'd sqrt(std)'
> std = subwrd(result,4)
> say 'STD DEV = ',std
> return
>
>
> Dr Raj Kumar
>
>
> <http://sigads.rediff.com/RealMedia/ads/click_nx.ads/www.rediffmail.com/signatureline.htm@Middle?>
--
Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.
********************************************************************
Charles Seman Charles.Seman at noaa.gov
U.S. Department of Commerce / NOAA / OAR
Geophysical Fluid Dynamics Laboratory voice: (609) 452-6547
201 Forrestal Road fax: (609) 987-5063
Princeton, NJ 08540-6649 http://www.gfdl.noaa.gov/~cjs/
********************************************************************
"The contents of this message are mine personally and do not necessarily
reflect any position of the Government or NOAA."
More information about the gradsusr
mailing list