java.lang.Object | ||
↳ | org.rrd4j.data.Plottable | |
↳ | org.rrd4j.data.LinearInterpolator |
Class used to interpolate datasource values from the collection of (timestamp, values) points. This class is suitable for linear interpolation only.
Interpolation algorithm returns different values based on the value passed to
setInterpolationMethod()
. If not set, interpolation
method defaults to standard linear interpolation (INTERPOLATE_LINEAR
).
Interpolation method handles NaN datasource
values gracefully.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | INTERPOLATE_LEFT | constant used to specify LEFT interpolation. | |||||||||
int | INTERPOLATE_LINEAR | constant used to specify LINEAR interpolation (default interpolation method). | |||||||||
int | INTERPOLATE_REGRESSION | constant used to specify LINEAR REGRESSION as interpolation method. | |||||||||
int | INTERPOLATE_RIGHT | constant used to specify RIGHT interpolation. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates LinearInterpolator from arrays of timestamps and corresponding datasource values.
| |||||||||||
Creates LinearInterpolator from arrays of timestamps and corresponding datasource values.
| |||||||||||
Creates LinearInterpolator from arrays of timestamps and corresponding datasource values.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Method overriden from the base class.
| |||||||||||
Sets interpolation method to be used.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
constant used to specify LEFT interpolation.
See setInterpolationMethod()
for explanation.
constant used to specify LINEAR interpolation (default interpolation method).
See setInterpolationMethod()
for explanation.
constant used to specify LINEAR REGRESSION as interpolation method.
See setInterpolationMethod()
for explanation.
constant used to specify RIGHT interpolation.
See setInterpolationMethod()
for explanation.
Creates LinearInterpolator from arrays of timestamps and corresponding datasource values.
timestamps | timestamps in seconds |
---|---|
values | corresponding datasource values |
IllegalArgumentException | Thrown if supplied arrays do not contain at least two values, or if timestamps are not ordered, or array lengths are not equal. |
---|
Creates LinearInterpolator from arrays of timestamps and corresponding datasource values.
dates | Array of Date objects |
---|---|
values | corresponding datasource values |
IllegalArgumentException | Thrown if supplied arrays do not contain at least two values, or if timestamps are not ordered, or array lengths are not equal. |
---|
Creates LinearInterpolator from arrays of timestamps and corresponding datasource values.
dates | array of GregorianCalendar objects |
---|---|
values | corresponding datasource values |
IllegalArgumentException | Thrown if supplied arrays do not contain at least two values, or if timestamps are not ordered, or array lengths are not equal. |
---|
Method overriden from the base class. This method will be called by the framework. Call this method only if you need interpolated values in your code.
timestamp | timestamp in seconds |
---|
Sets interpolation method to be used. Suppose that we have two timestamp/value pairs:
(t, 100)
and (t + 100, 300)
. Here are the results interpolator
returns for t + 50 seconds, for various interpolationMethods
:
INTERPOLATE_LEFT: 100
INTERPOLATE_RIGHT: 300
INTERPOLATE_LINEAR: 200
INTERPOLATE_LINEAR
.The fourth available interpolation method is INTERPOLATE_REGRESSION. This method uses simple linear regression to interpolate supplied data with a simple straight line which does not necessarily pass through all data points. The slope of the best-fit line will be chosen so that the total square distance of real data points from from the best-fit line is at minimum.
The full explanation of this inteprolation method can be found here.
interpolationMethod | Should be INTERPOLATE_LEFT ,
INTERPOLATE_RIGHT , INTERPOLATE_LINEAR or
INTERPOLATE_REGRESSION . Any other value will be interpreted as
INTERPOLATE_LINEAR (default).
|
---|