SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWInterval< T > Class Template Reference

A class template for describing an interval of values. More...

#include <rw/analytics/interval.h>

Public Types

enum  Type { open , closed , openClosed , closedOpen }
 

Public Member Functions

 RWInterval ()
 
 RWInterval (const RWInterval< T > &i)
 
 RWInterval (T a, T b, Type t)
 
bool contains (T x)
 
lowerBound () const
 
RWInterval< T > & operator= (const RWInterval< T > &rhs)
 
void setBound (T x)
 
void setBounds (T a, T b)
 
void setType (Type t)
 
Type type () const
 
upperBound () const
 

Related Symbols

(Note that these are not member symbols.)

template<class T >
bool operator== (const RWInterval< T > &lhs, const RWInterval< T > &rhs)
 

Detailed Description

template<class T>
class RWInterval< T >

RWInterval 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 Linear Algebra Module, the class RWInterval is used to describe confidence intervals for regression predictions and parameter estimates.

Synopsis
#include <rw/analytics/interval.h>
A class template for describing an interval of values.
Definition interval.h:80
Example

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/interval.h>
#include <rw/analytics/linregress.h>
int 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;
}
A templatized general matrix class.
Definition genmat.h:741
T lowerBound() const
Definition interval.h:141
T upperBound() const
Definition interval.h:146
Constructs a linear regression model from a matrix of predictor variable data and a vector of observa...
Definition linregress.h:96
A templatized vector class.
Definition mathvec.h:667

Member Enumeration Documentation

◆ Type

template<class T >
enum RWInterval::Type

If the left endpoint is a and the right endpoint is b, and \(a \leq b\)

then the values of the Type enumeration have the following meanings:

Enumerator
open 

(a,b)

closed 

[a,b]

openClosed 

(a,b]

closedOpen 

[a,b)

Constructor & Destructor Documentation

◆ RWInterval() [1/3]

template<class T >
RWInterval< T >::RWInterval ( )
inline

Constructs an empty interval.

◆ RWInterval() [2/3]

template<class T >
RWInterval< T >::RWInterval ( T a,
T b,
Type t )
inline

Constructs an interval of type t with endpoints a and b.

◆ RWInterval() [3/3]

template<class T >
RWInterval< T >::RWInterval ( const RWInterval< T > & i)
inline

Constructs a copy of i.

Member Function Documentation

◆ contains()

template<class T >
bool RWInterval< T >::contains ( T x)
inline

Returns true if the interval contains x, otherwise returns false.

◆ lowerBound()

template<class T >
T RWInterval< T >::lowerBound ( ) const
inline

Returns the interval's lower bound.

◆ operator=()

template<class T >
RWInterval< T > & RWInterval< T >::operator= ( const RWInterval< T > & rhs)
inline

Sets self equal to rhs.

◆ setBound()

template<class T >
void RWInterval< T >::setBound ( T x)
inline

Sets the interval's upper bound to x if x is greater than the current upper bound. Otherwise, sets the lower bound to x.

◆ setBounds()

template<class T >
void RWInterval< T >::setBounds ( T a,
T b )
inline

Sets the interval's lower bound to the smaller of the two values and the upper bound to the larger of the two values.

◆ setType()

template<class T >
void RWInterval< T >::setType ( Type t)
inline

Sets the interval's type to t.

◆ type()

template<class T >
Type RWInterval< T >::type ( ) const
inline

Returns the interval's type.

◆ upperBound()

template<class T >
T RWInterval< T >::upperBound ( ) const
inline

Returns the interval's upper bound.

Friends And Related Symbol Documentation

◆ operator==()

template<class T >
bool operator== ( const RWInterval< T > & lhs,
const RWInterval< T > & rhs )
related

Returns true if the intervals have the same endpoints and type.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.