|
Math::Interpolate - Interpolate the value Y from X using a list of pairs |
Math::Interpolate - Interpolate the value Y from X using a list of (X, Y) pairs
use Math::Interpolate qw(derivatives constant_interpolate
linear_interpolate robust_interpolate);
my @x = (1..5);
my @y = (5, 10, 13, -4.5, 3);
my @dy = derivatives(\@x, \@y);
my ($l_y, $l_dy) = linear_interpolate(3.4, \@x, \@y);
my ($r_y, $r_dy) = robust_interpolate(3.4, \@x, \@y);
($r_y, $r_dy) = robust_interpolate(3.4, \@x, \@y, [-2, 3, 4, -1, 4]);
If there is an error in the input, such as x_sequence and y_sequence containing a different number of elements, then the subroutine returns an empty list in list context, an undefined value in scalar context, or nothing in a void context.
then return y_sequence->[i]
If x is less than x_sequence->[0], then return y_sequence->[0]. If x is greater than x_sequence-[-1], then return y_sequence->[-1].
If there is an error in the input, such as x_sequence and y_sequence containing a different number of elements, then the subroutine returns an empty list in list context, an undefined value in scalar context, or nothing in a void context.
In an array context, linear_interpolate will return an array containing the y value and and slope between the two nearest surrounding points.
If there is an error in the input, such as x_sequence and y_sequence containing a different number of elements, then the subroutine returns an empty list in list context, an undefined value in scalar context, or nothing in a void context.
The returned value y lies on the curve between the two points surrounding x. If <x> lies outside of the range of values spanned by x_sequence then a linear extrapolation will be done.
In an array context, linear_interpolate will return an array containing the y value and and slope between the two nearest surrounding points.
If there is an error in the input, such as x_sequence and y_sequence containing a different number of elements, then the subroutine returns an empty list in list context, an undefined value in scalar context, or nothing in a void context.
Blair Zajac <bzajac@geostaff.com>.
Copyright (c) 1998 by Blair Zajac.
|
Math::Interpolate - Interpolate the value Y from X using a list of pairs |