Performs linear & inverse linear interpolation between variates (R.J. Reader).
||Type of interpolation required (
||Whether the smallest value, largest value or the mean of the two is returned if more than one value is valid (
||Each one contains variates specifying the y-values (data values) with which an interpolation is to be carried out|
||Contains the x-values (intervals) corresponding to the variates in the
VINTERPOLATE performs linear interpolation and inverse linear interpolation between variates, as was given by the Genstat 4 functions
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
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.
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.
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.
Commands for: Calculations and manipulation.
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,Y4,Y20); 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,X50,X75) PRINT X10,X50,X75