Performs linear & inverse linear interpolation between variates (R.J. Reader).
Options
METHOD = string token |
Type of interpolation required (interval , value ): for METHOD=value , y-values are interpolated for each point in the NEWINTERVALS variates and stored in the NEWVALUES variates, while for METHOD=interval , x-values are estimated for the y-values in the NEWVALUES variates and stored in the NEWINTERVALS variates; default inte |
---|---|
RANGEMETHOD = string token |
Whether the smallest value, largest value or the mean of the two is returned if more than one value is valid (first , middle , last ); default midd |
Parameters
OLDVALUES = pointers |
Each one contains variates specifying the y-values (data values) with which an interpolation is to be carried out |
---|---|
NEWVALUES = pointers |
For METHOD=value , each pointer contains variates to store the results of an interpolation; for METHOD=interval , it contains either variates or scalars to specify y-values for which inverse interpolation is to be carried out |
OLDINTERVALS = variates |
Contains the x-values (intervals) corresponding to the variates in the OLDVALUES pointer |
NEWINTERVALS = pointers |
For METHOD=interval , each pointer contains variates to store the results of an inverse interpolation; for METHOD=value , it contains either variates or scalars to specify x-values at which interpolation is to be performed |
Description
VINTERPOLATE
performs linear interpolation and inverse linear interpolation between variates, as was given by the Genstat 4 functions LINT
and INLINT
. The y-values (or data values) are given in a set of variates, contained in the pointer specified by the OLDVALUES
parameter. The corresponding x-values (intervals) are specified by the OLDINTERVALS
parameter, in a variate with one value for each variate of the OLDVALUES
pointer. For interpolation (METHOD=value
), values are interpolated at the x-values specified by the variates or scalars contained in the NEWINTERVALS
pointer, and are stored in variates contained in the NEWVALUES
parameter. For inverse interpolation (METHOD=interval
), x-values are estimated for the y-values specified by the variates or scalars contained in the NEWVALUES
pointer, and are stored in variates contained in the NEWINTERVALS
pointer. Where two or more successive OLDINTERVALS
or OLDVALUES
are the same, there is no unique solution to the interpolation; the RANGEMETHOD
option allows the smallest (RANGEMETHOD=first
), largest (RANGEMETHOD=last
) or the mean of these two (RANGEMETHOD=middle
) values or intervals to be selected.
Options: METHOD
, RANGEMETHOD
.
Parameters: OLDVALUES
, NEWVALUES
, OLDINTERVALS
, NEWINTERVALS
.
Method
An estimate of the required value is calculated from each successive pair of points. If this estimate is between the two points from which it was calculated, it is a valid answer i.e. it was produced by interpolation not extrapolation. If it does not satisfy this condition it is set to missing. If the curve is horizontal or vertical at the point of interpolation, more than one point will satisfy the above condition. In this case the value returned will depend on the setting of the option RANGEMETHOD
. This will determine whether the smallest value found, the largest value found, or the mean of these two values is returned. The default is to return the mean value.
Action with RESTRICT
If any of the variates in the OLDVALUES
pointer is restricted, the other variates in the pointer must either have the same restriction or be unrestricted. Missing values are then returned for the units excluded by the restriction. The OLDINTERVALS
variate must not be restricted.
See also
Directive: INTERPOLATE
.
Procedure: VREGRESS
.
Commands for: Calculations and manipulation.
Example
CAPTION 'VINTERPOLATE example'; STYLE=meta VARIATE Y[1...10]; VALUES=!( 0, 0, 0, 22, 2, 0, 0, 2),\ !( 0, 3, 0, 19, 23, 0, 10, 60),\ !( 7, 53, 1, 10, 54, 7, 27, 84),\ !(40, 68, 11, 10, 63, 12, 31, 88),\ !(46, 69, 16, 6, 64, 12, 31, 88),\ !(51, 70, 17, 6, 65, 15, 33, 88),\ !(52, 71, 17, 3, 65, 15, 33, 88),\ !(52, 71, 18, 0, 65, 15, 33, 88),\ !(66, 71, 63, 0, 65, 15, 34, 88),\ !(66, 71, 65, 0, 65, 15, 34, 88) & [VALUES=1,4,7,10,13,16,19,22,25,28] X FOR [NTIMES=1] CAPTION !t('The data are contained in the variates Y[1...10], whose',\ 'values were observed at the times stored in the variate X.') PRINT [RLWIDTH=1; ORIENTATION=across; SQUASH=yes] X; FIELD=7; DECIMALS=0 PRINT [INDENT=1] Y[]; FIELD=7; DECIMALS=0 ENDFOR CAPTION 'Interpolate values for times 2, 4 and 20.' VINTERPOLATE [METHOD=value] OLDVALUES=Y; OLDINTERVALS=X;\ NEWVALUES=!P(Y2[1],Y4[1],Y20[1]); NEWINTERVALS=!P(2,4,20) PRINT Y2[],Y4[],Y20[] CAPTION !t('Use inverse interpolation to obtain the times',\ 'at which the values 10, 50 and 75 were reached.',\ 'RANGE option set to take the smallest value from ties.') VINTERPOLATE [RANGE=first] OLDVALUES=Y; OLDINTERVALS=X;\ NEWVALUES=!P(10,50,75); NEWINTERVALS=!P(X10[1],X50[1],X75[1]) PRINT X10[],X50[],X75[]