[Previous]
[Next]
NAME:
KRIG_2D
PURPOSE:
This function interpolates a regularly or irregularly gridded
set of points Z = F(X,Y) using kriging.
CATEGORY:
Interpolation, Surface Fitting
CALLING SEQUENCE:
Result = KRIG2D(Z [, X, Y])
INPUTS:
X, Y, Z: arrays containing the X, Y, and Z coordinates of the
data points on the surface. Points need not be
regularly gridded. For regularly gridded input data,
X and Y are not used: the grid spacing is specified
via the XGRID and YGRID (or XVALUES and YVALUES)
keywords, and Z must be a two dimensional array.
For irregular grids, all three parameters must be
present and have the same number of elements.
KEYWORD PARAMETERS:
Model Parameters:
EXPONENTIAL: if set (with parameters [A, C0, C1]), use an exponential
semivariogram model.
SPHERICAL: if set (with parameters [A, C0, C1]), use a spherical
semivariogram model.
Both models use the following parameters:
A: the range. At distances beyond A, the semivariogram
or covariance remains essentialy constant.
See the definition of the functions below.
C0: the "nugget," which provides a discontinuity at the
origin.
C1: the covariance value for a zero distance, and the variance
of the random sample Z variable. If only a two element
vector is supplied, C1 is set to the sample variance.
(C0 + C1) = the "sill," which is the variogram value for
very large distances.
Input grid description:
REGULAR: if set, the Z parameter is a two dimensional array
of dimensions (N,M), containing measurements over a
regular grid. If any of XGRID, YGRID, XVALUES, YVALUES
are specified, REGULAR is implied. REGULAR is also
implied if there is only one parameter, Z. If REGULAR is
set, and no grid (_VALUE or _GRID) specifications are
present, the respective grid is set to (0, 1, 2, ...).
XGRID: contains a two element array, [xstart, xspacing],
defining the input grid in the X direction. Do not
specify both XGRID and XVALUES.
XVALUES: if present, XVALUES(i) contains the X location
of Z(i,j). XVALUES must be dimensioned with N elements.
YGRID: contains a two element array, [ystart, yspacing],
defining the input grid in the Y direction. Do not
specify both YGRID and YVALUES.
YVALUES: if present, YVALUES(i) contains the Y location
of Z(i,j). YVALUES must be dimensioned with N elements.
Output grid description:
GS: If present, GS must be a two-element vector [XS, YS],
where XS is the horizontal spacing between grid points
and YS is the vertical spacing. The default is based on
the extents of X and Y. If the grid starts at X value
Xmin and ends at Xmax, then the default horizontal
spacing is (Xmax - Xmin)/(NX-1). YS is computed in the
same way. The default grid size, if neither NX or NY
are specified, is 26 by 26.
BOUNDS: If present, BOUNDS must be a four element array containing
the grid limits in X and Y of the output grid:
[Xmin, Ymin, Xmax, Ymax]. If not specified, the grid
limits are set to the extent of X and Y.
NX: The output grid size in the X direction. NX need not
be specified if the size can be inferred from GS and
BOUNDS. The default value is 26.
NY: The output grid size in the Y direction. See NX.
OUTPUTS:
This function returns a two dimensional floating point array
containing the interpolated surface, sampled at the grid points.
CALLS: ***
KRIG2D, KRIG_EXPON, KRIG_SPHERE
RESTRICTIONS:
The accuracy of this function is limited by the single precision
floating point accuracy of the machine.
SAMPLE EXECUTION TIMES (measured on a Sun IPX)
# of input points # of output points Seconds
10 676 1.1
20 676 1.5
40 676 2.6
80 676 7.8
10 1024 1.6
10 4096 5.9
10 16384 23
PROCEDURE:
Ordinary kriging is used to fit the surface described by the
data points X,Y, and Z. See: Isaaks and Srivastava,
"An Introduction to Applied Geostatistics," Oxford University
Press, 1989, Chapter 12.
The parameters of the data model, the range, nugget, and
sill, are highly dependent upon the degree and type of spatial
variation of your data, and should be determined statistically.
Experimentation, or preferrably rigorus analysis, is required.
For N data points, a system of N+1 simultaneous
equations are solved for the coefficients of the
surface. For any interpolation point, the interpolated value
is:
F(x,y) = Sum( w(i) * C(x(i),y(i), x, y)
Formulas used to model the variogram functions:
d(i,j) = distance from point i to point j.
V = variance of samples.
C(i,j) = Covariance of sample i with sample j.
C(x0,y0,x1,y1) = Covariance of point (x0,y0) with (x1,y1).
Exponential covar: C(d) = C1 * EXP(-3*d/A) if d ne 0.
= C1 + C0 if d eq 0.
Spherical covar: C(d) = (1.0 - 1.5 * d/a + 0.5 * (d/a)^3)
= C1 + C0 if d eq 0.
= 0 if d > a.
EXAMPLES:
Example 1: Irregularly gridded cases
Make a random set of points that lie on a gaussian:
n = 15 ;# random points
x = RANDOMU(seed, n)
y = RANDOMU(seed, n)
z = exp(-2 * ((x-.5)^2 + (y-.5)^2)) ;The gaussian
get a 26 by 26 grid over the rectangle bounding x and y:
e = [ 0.25, 0.0] ;Range and nugget are 0.25, and 0.
;(These numbers are dependent upon
;your data model.)
r = krig2d(z, x, y, EXPON = e) ;Get the surface.
Or: get a surface over the unit square, with spacing of 0.05:
r = krig2d(z, x, y, EXPON=e, GS=[0.05, 0.05], BOUNDS=[0,0,1,1])
Or: get a 10 by 10 surface over the rectangle bounding x and y:
r = krig2d(z, x, y, EXPON=e, NX=10, NY=10)
Example 2: Regularly gridded cases
s = [ 10., 0.2] ;Range and sill, data dependent.
z = randomu(seed, 5, 6) ;Make some random data
interpolate to a 26 x 26 grid:
CONTOUR, krig2d(z, /REGULAR, SPHERICAL = s)
MODIFICATION HISTORY:
DMS, RSI, March, 1993. Written.
GSL, RSI, October 1997. Replaced obsolete LUDCMP,LUBKSB with
LUDC and LUSOL.
CT, RSI, July 2003: Subtract fudge factor when computing NX, NY
to avoid roundoff errors.
[Previous]
[Next]
NAME:
KURTOSIS
PURPOSE:
This function computes the statistical kurtosis of an
N-element vector. If the variance of the vector is zero,
the kurtosis is not defined, and KURTOSIS returns
!VALUES.F_NAN as the result.
CATEGORY:
Statistics.
CALLING SEQUENCE:
Result = KURTOSIS(X)
INPUTS:
X: An N-element vector of type integer, float or double.
KEYWORD PARAMETERS:
DOUBLE: IF set to a non-zero value, computations are done in
double precision arithmetic.
NAN: If set, treat NaN data as missing.
CALLS: ***
MOMENT
EXAMPLE:
Define the N-element vector of sample data.
x = [65, 63, 67, 64, 68, 62, 70, 66, 68, 67, 69, 71, 66, 65, 70]
Compute the mean.
result = KURTOSIS(x)
The result should be:
-1.18258
PROCEDURE:
KURTOSIS calls the IDL function MOMENT.
REFERENCE:
APPLIED STATISTICS (third edition)
J. Neter, W. Wasserman, G.A. Whitmore
ISBN 0-205-10328-6
MODIFICATION HISTORY:
Written by: GSL, RSI, August 1997
[Previous]
[Next]
NAME:
KW_TEST
PURPOSE:
This function tests the hypothesis that three or more sample
popultions have the same mean of distribution against the
hypothesis that they differ. The popultions may be of equal
or unequal lengths. The result is a two-element vector containing
the test statistic H and the one-tailed probability of obtaining
a value of H or greater from a chi-square distribution. This type
of test is often refered to as the Kruskal-Wallis H-Test.
CATEGORY:
Statistics.
CALLING SEQUENCE:
Result = KW_test(X)
INPUTS:
X: An array of m-columns (m >= 3) and n-rows of type integer,
float or double. The columns of this two dimensional array
correspond to the sample popultions. If the sample popultions
are of unequal length, all vectors must be appended up to a
common length of n using a user-specified missing value. This
method requires the use of the MISSING keyword.
KEYWORD PARAMETERS:
DF: Use this keyword to specify a named variable which returns
the degrees of freedom used to compute the probability of
obtaining a value of H or greater from the corresponding
chi-square distribution
MISSING: Use this keyword to specify a non-zero numeric value which
is used to appended popultions of unequal length up to a
common length of n.
CALLS: ***
CHISQR_PDF, IDL_CRANK
EXAMPLE:
Test the hypothesis that three sample popultions have the same mean
of distribution against the hypothesis that they differ at the 0.05
significance level.
sp0 = [24.0, 16.7, 22.8, 19.8, 18.9]
sp1 = [23.2, 19.8, 18.1, 17.6, 20.2, 17.8]
sp2 = [18.2, 19.1, 17.3, 17.3, 19.7, 18.9, 18.8, 19.3]
Since the sample popultions are of unequal lengths, a missing value
must be appended to sp0 and sp1. In this example the missing value
is -1.0 and the 3-column, 8-row input array is defined as:
x = [[24.0, 23.2, 18.2], $
[16.7, 19.8, 19.1], $
[22.8, 18.1, 17.3], $
[19.8, 17.6, 17.3], $
[18.9, 20.2, 19.7], $
[-1.0, 17.8, 18.9], $
[-1.0, -1.0, 18.8], $
[-1.0, -1.0, 19.3]]
result = kw_test(x, missing = -1)
The result should be the 2-element vector:
[1.65862, 0.436351]
The computed probability (0.436351) is greater than the 0.05
significance level and therefore we do not reject the hypothesis
that the three sample popultions s0, s1 and s2 have the same mean
of distribution.
PROCEDURE:
KW_TEST computes the nonparametric Kruskal-Wallis H-Test for three or
more populations of equal or unequal size. This test is an extension
of the Rank Sum Test implemented in the RS_TEST function. When each
sample population contains at least five observations, the H test
statistic is approximated very well by a chi-square distribution with
DF degrees of freedom. The hypothesis that three of more sample
populations have the same mean of distribution is rejected if two or
more populations differ with statistical significance.
REFERENCE:
PROBABILITY and STATISTICS for ENGINEERS and SCIENTISTS (3rd edition)
Ronald E. Walpole & Raymond H. Myers
ISBN 0-02-424170-9
MODIFICATION HISTORY:
Written by: GGS, RSI, September 1994