stat2, stat_trim, stat4, stat_medrng

For each index of dimensions 0...n-2, these procedures calculate estimates, variances, skewnesses, kurtoses, medians, ranges, and mid-ranges on moments of the n-1 dimension.


Synopsis

    procedure stat2(
        x       : float,
        xmean   : float,
        xvar    : float,
        nptused : integer
    )

    procedure stat_trim(
        x      : float,
        ptrim  : float,
        xmeant : float,
        xsdt   : float
    )

    procedure stat4(
        x       : float,
        xmean   : float,
        xvar    : float,
        xskew   : float,
        xkurt   : float,
        nptused : integer
    )

    procedure stat_medrng(
        x       : float,
        xmedian : float,
        xmrange : float,
        xrange  : float,
        nptused : integer
    )

Arguments

x
Input array of any dimensionality. Missing values should be indicated by x@_FillValue. If x@_FillValue is not set, then the NCL default (-999) will be assumed.
xmean
Mean of x (output, same dimensions as x, with last dimension omitted). Space for this variable must be explicitly allocated by the user.
xmeant
Mean of trimmed x (output, same dimensions as xmean). Space for this variable must be explicitly allocated by the user.
xvar
Sample variance of x (output, same dimensions as xmean). Space for this variable must be explicitly allocated by the user.
xsdt
Sample standard deviation of trimmed x (output, same dimensions as xmean). Space for this variable must be explicitly allocated by the user.
xskew
Coefficient of skewness (output, same dimensions as xmean). Space for this variable must be explicitly allocated by the user.
xkurt
Coefficient of kurtosis (output, same dimensions as xmean). Space for this variable must be explicitly allocated by the user.
xmedian
Median value of x (output, same dimensions as xmean). Space for this variable must be explicitly allocated by the user.
xmrange
Mid-range value of x (output, same dimensions as xmean). Space for this variable must be explicitly allocated by the user.
xrange
Range of x (output, same dimensions as xmean). Space for this variable must be explicitly allocated by the user.
nptused
Number of points used (output, same dimensions as xmean). Space for this variable must be explicitly allocated by the user.
ptrim
Scalar, portion of series to be trimmed (0. <= ptrim < 1.). If ptrim = 0, then calculate the whole series mean and standard deviation. Otherwise, a minimum of two points will be trimmed.


Description

Note for the procedures below: for dimensions 0 to n-2, the calculations are done on the last dimension (n-1th dimension) of the input array. The output arrays are the same dimensions as the first 0 to n-2 dimensions of the input (if the input is a singly-dimensioned array, then the output will be a scalar). Because the output values are part of the procedure calls, you must allocate the output arrays before the procedure is called. Some examples are shown below.

stat2 calculates the first two moments of the n-1 dimension of x containing missing data. This function returns the sample variance.

stat_trim calculates trimmed estimates of the first two moments of the vectors in x containing missing data.

stat4 calculates estimates of the first four moments (mean, variance, skewness, and kurtosis) of the vectors in x containing missing data. This function returns the sample variance.

stat_medrng calculates median, range, and mid-range of the vectors in x containing missing data.


Example

Run the following example and then print out xmean, xvar, xskew, xkurt, and npts to see how stat2 and stat4 work.

begin
;
; Define a 3 x 2 x 2 array
;
   x = (/(/(/1.,2./),(/3.,4./)/),(/(/5.,6./),(/-999,8./)/),\
         (/(/9.,10./),(/11.,-999/)/)/)
   x@_FillValue = -999

   xmean   = new((/3,2/),float)
   xvar    = new((/3,2/),float)
   xskew   = new((/3,2/),float)
   xkurt   = new((/3,2/),float)
   npts    = new((/3,2/),integer)   

   stat2(x,xmean,xvar,npts)
   print(xmean)
   print(xvar)
   print(npts)

   stat4(x,xmean,xvar,xskew,xkurt,npts)
   print(xmean)
   print(xvar)
   print(xskew)
   print(xkurt)
   print(npts)
end


Reference Manual Control Panel

NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?


$Revision: 1.8 $ $Date: 1999/03/22 20:49:11 $