DESPT

Estimates a probability density function at specified points using linear or cubic interpolation.

Required Arguments

XPT — Vector of length NODE containing the points at which an estimate of the probability density is desired. (Input)

AMESH — Vector of length NORD for IOPT = 2 or 4, and of length 2 for IOPT = 1 or 3. (Input)
If IOPT = 2 or 4, AMESH(I) contains the abscissas corresponding to each density estimate in DENS(I). In this case, the abscissas must be specified in increasing order. If IOPT = 1 or 3 (i.e., for an equally spaced mesh), then the lower and upper ends of the mesh are specified by AMESH(1) and AMESH(2), respectively, with the increment between mesh points given by (AMESH(2)   AMESH(1))/(NORD  1).

DENS — Vector of length NORD containing the density function values corresponding to each of the NORD abscissa values. (Input)

DENEST — Vector of length NODE containing the density function estimates for the points in XPT. (Output)

Optional Arguments

NODE — Number of points at which the density is desired. (Input)
Default: NODE = size (XPT,1).

IOPT — Interpolation option parameter. (Input)
Default: IOPT = 1.

 

IOPT

Method of interpolation

1

Linear on equally spaced points

2

Linear with unequal spacing

3

Cubic on equally spaced points

4

Cubic with unequal spacing

NORD — Number of ordinates supplied. (Input)
NORD must be greater than one for linear interpolation, and greater than three for cubic interpolation.
Default: NORD = size (DENS,1).

FORTRAN 90 Interface

Generic: CALL DESPT (XPT, AMESH, DENS, DENEST [])

Specific: The specific interface names are S_DESPT and D_DESPT.

FORTRAN 77 Interface

Single: CALL DESPT (NODE, XPT, IOPT, NORD, AMESH, DENS, DENEST)

Double: The double precision name is DDESPT.

Description

Routine DESPT computes an estimate of a density function using either linear or cubic spline interpolation on a set {(XiFi), for i = 1, N}, where Fi = DENS(i), N = NODE, and where the values of the the grid points Xi can be obtained from the vector AMESH. The value of IOPT indicates the type of interpolation (linear or cubic) to be performed and whether the mesh values are equally spaced. When IOPT is 1 or 3, then an equally spaced mesh is used with mesh values given by

AMESH (1) + i * DELTA

for i = 0, 1, N – 1, where

DELTA = (AMESH(2)  AMESH(1))/(NORD  1)

IOPT = 2 or 4 yields an unequally spaced mesh with all mesh values contained in the vector AMESH.

The Akima cubic spline method of interpolation (Akima 1970) is used for the cubic interpolation.

Comments

1. Workspace may be explicitly provided, if desired, by use of D2SPT/DD2SPT . The reference is:

CALL D2SPT (NODE, XPT, IOPT, NORD, AMESH, DENS, DENEST, CF, X, BREAK)

The additional arguments are as follows:

CF — Work vector of length 4 * NORD for IOPT = 3 or 4. CF is not used for other values of IOPT and may be dimensioned of length 1.

X — Work vector of length NORD for IOPT = 3 or 4. X is not used for other values of IOPT and may be dimensioned of length 1.

BREAK — Work vector of length NORD for IOPT = 3 or 4. BREAK is not used for other values of IOPT and may be dimensioned of length 1.

2. Array AMESH is the same as array BNDS in DESPL when IOPT is 1 or 3, and the same as array XPT in DESKN when IOPT is 2 or 4.

Example

The standard normal density is to be estimated via a grid of points over which the density is provided. Grid points are given by (0.0, 0.5, 1.0, 1.5, 2.0) while the density is to be estimated (via linear interpolation) at the four points (0.25, 0.75, 1.25, 1.75). For comparison, both the exact and the estimated density values at each of the four points are printed.

 

USE DESPT_INT

USE UMACH_INT

 

IMPLICIT NONE

INTEGER NODE, NORD

PARAMETER (NODE=4, NORD=5)

!

INTEGER I, NOUT

REAL AMESH(2), DENEST(NODE), DENS(NORD), EXP, F, H, X, X0, &

XPT(NODE)

INTRINSIC EXP

!

DATA XPT/0.25, 0.75, 1.25, 1.75/

DATA AMESH/0, 2/

!

F(X) = 0.3989423*EXP(-X*X/2.0)

! Get the grid values

H = (AMESH(2)-AMESH(1))/(NORD-1)

X0 = AMESH(1)

DO 10 I=1, NORD

DENS(I) = F(X0)

X0 = X0 + H

10 CONTINUE

! Get the density estimates

CALL DESPT (XPT, AMESH, DENS, DENEST)

! Print the results

CALL UMACH (2, NOUT)

WRITE (NOUT,'('' X DENEST EXACT'')')

DO 20 I=1, NODE

WRITE (NOUT,'(F5.2, 2F12.5)') XPT(I), DENEST(I), F(XPT(I))

20 CONTINUE

END

Output

 

X DENEST EXACT

0.25 0.37550 0.38667

0.75 0.29702 0.30114

1.25 0.18574 0.18265

1.75 0.09175 0.08628