|
|
| |
Math::Interpolate(3) |
User Contributed Perl Documentation |
Math::Interpolate(3) |
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]);
- derivatives x_sequence y_sequence
- Given a reference to an array of x values in x_sequence and a
reference to an array of y values in y_sequence, return an array of
reasonable derivatives. The x_sequence values are presumed to be
sorted in increasing numerical order.
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.
- constant_interpolate x x_sequence
y_sequence
- Given a reference to an array of x values in x_sequence and a
reference to an array of y values in y_sequence, return the y value
associated with the first x value less than or equal to x. In other
words, if
x_sequence->[i] <= x < x_sequence->[i+1]
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.
- linear_interpolate x x_sequence
y_sequence
- Given a reference to an array of x values in x_sequence and a
reference to an array of y values in y_sequence, calculate the
interpolated value y that corresponds to the value x. The returned
value y lies on the straight line 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.
- robust_interpolate value x_sequence y_sequence
[dy_sequence]
- Given a reference to an array of x values in x_sequence and a
reference to an array of y values in y_sequence, calculate the
interpolated value y that corresponds to the value x. The
interpolated curve generated by robust_interpolate is smooth and
even the derivatives of the curve are smooth with only a few exceptions.
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 <blair@orcaware.com>.
Copyright (C) 1998-2005 Blair Zajac. All rights reserved. This package is free
software; you can redistribute it and/or modify it under the same terms as
Perl itself.
Hey! The above document had some coding errors, which are explained
below:
- Around line 354:
- =back doesn't take any parameters, but you said =back 4
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc. |