
>
| Data Types | |
| Type |
| Member Functions | |||
| contains() lowerBound() operator=() |
operator==() setBound() setBounds() |
setType() type() upperBound() |
>#include <rw/analytics/interval.h> RWInterval<double> ci( -1.031, 2.045, RWInterval<double>::closed);
RWInterval<T> is a general-purpose class for describing an interval of values. The values in the interval are of type T. An interval may be considered a set of contiguous values where the interval endpoints are either included or excluded from the set. If an interval's endpoints are excluded, it is said to be open; if the endpoints are included, the interval is said to be closed.
In Analytics.h++, the class RWInterval<T> is used to describe confidence intervals for regression predictions and parameter estimates.
>The following example prints the linear regression prediction interval for the first pattern in the predictor matrix at a confidence level of 99 percent.
#include <rw/analytics/linregress.h>
#include <rw/analytics/interval.h>
main() {
RWGenMat<double> predictorMatrix =
"5x2 [1.2 2.1 8 7 3 3.2 6.4 4.6 2 2.3]";
RWMathVec<double> observationVector = "[2.5 3.7 1.4 2.3 5.6]";
RWLinearRegression lr(predictorMatrix, observationVector);
RWMathVec<double> firstPredPattern = predictorMatrix(0,RWAll);
RWInterval<double> interval =
lr.predictionInterval(firstPredPattern, 0.01);
cout << "Interval lower bound: " << interval.lowerBound() <<
endl;
cout << "Interval upper bound: " << interval.upperBound() <<
endl;
return 0;
}
>
enum Type {open, closed, openClosed, closedOpen}
If the left endpoint is a and the right endpoint is b, and
, then the values of the Type enumeration have the following meanings:
| open | - (a,b) |
| closed | - [a,b] |
| openClosed | - (a,b] |
| closedOpen | - [a,b) |
RWInterval();
Constructs an empty interval.
RWInterval(T lb, T up, RWInterval<T>::Type t);
Constructs an interval of type t with endpoints lb and up.
RWInterval(const RWInterval<T>& i);
Constructs a copy of i.
RWBoolean contains(T x) const;
Returns TRUE if the interval contains x, otherwise returns FALSE.
T lowerBound() const;
Returns the interval's lower bound.
void setBound(T x);
Sets the interval's upper bound to x if x is greater than the current upper bound. Otherwise, sets the lower bound to x.
void setBounds(T x, T y) const;
Sets the interval's lower bound to the smaller of the two values and the upper bound to the larger of the two values.
void setType(RWInterval<T>::Type t);
Sets the interval's type to t.
RWInterval<T>::Type type() const;
Returns the interval's type.
T upperBound() const;
Returns the interval's upper bound.
RWInterval<T>& operator=(const RWInterval<T>& i);
Sets self equal to i.
RWBoolean operator==(const RWInterval<T>& lhs,
const RWInterval<T>& rhs);
Returns TRUE if the intervals have the same endpoints and type.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.