|
STK++ 1.0
|
Compute a BSpline, multivalued, regression function using BSpline basis. More...
#include <STK_BSplineRegression.h>


Public Member Functions | |
| BSplineRegression (Matrix const *p_y, Vector const *p_x, Integer const &nbControlPoints, Integer const °ree=3, const _Kposition &position=BSplineCoefficients::uniform_) | |
| Constructor. | |
| virtual | ~BSplineRegression () |
| virtual destructor. | |
| Integer const & | degree () const |
| give the degree of the B-Spline curve. | |
| Integer const & | nbControlPoints () const |
| give the number of control points of the B-Spline curves. | |
| Matrix const & | controlPoints () const |
| give the control points. | |
| Vector const & | knots () const |
| give the knots. | |
| Matrix const & | coefficients () const |
| give the computed coefficients of the B-Spline curves. | |
Protected Member Functions | |
| virtual void | preRun () |
| compute the coefficients of the BSpline basis. | |
| virtual void | regression () |
| compute the regression function. | |
| virtual void | regression (Vector const &weights) |
| compute the regression function. | |
| virtual void | prediction () |
| Compute the predicted outputs by the regression function. | |
| virtual Integer | computeNbParameter () const |
| Compute the number of parameter of the regression function. | |
Protected Attributes | |
| Integer | nbControlPoints_ |
| number of control points of the B-Spline curve. | |
| Integer | degree_ |
| degree of the B_Spline curve | |
| _Kposition | position_ |
| method of position of the knots of the B-Spline curve | |
| BSplineCoefficients | coefs_ |
| Coefficients of the regression matrix. | |
| Matrix | controlPoints_ |
| Estimated control points of the B-Spline curve. | |
Private Types | |
| typedef BSplineCoefficients::KnotsPosition | _Kposition |
Compute a BSpline, multivalued, regression function using BSpline basis.
Definition at line 51 of file STK_BSplineRegression.h.
typedef BSplineCoefficients::KnotsPosition STK::BSplineRegression::_Kposition [private] |
Definition at line 54 of file STK_BSplineRegression.h.
| STK::BSplineRegression::BSplineRegression | ( | Matrix const * | p_y, |
| Vector const * | p_x, | ||
| Integer const & | nbControlPoints, | ||
| Integer const & | degree = 3, |
||
| const _Kposition & | position = BSplineCoefficients::uniform_ |
||
| ) |
Constructor.
| p_y | d-dimensional array of output to fit |
| p_x | uni-dimensional array of predictor |
| nbControlPoints | number of control points of the spline |
| degree | degree of the BSpline basis |
| position | position of the knots to used |
Definition at line 48 of file STK_BSplineRegression.cpp.
: IRegression<Matrix, Vector, Vector>(p_y, p_x)
, nbControlPoints_(nbControlPoints)
, degree_(degree)
, position_(position)
, coefs_(p_x, nbControlPoints_, degree_, position_)
, controlPoints_()
{ }
| STK::BSplineRegression::~BSplineRegression | ( | ) | [virtual] |
| Integer const& STK::BSplineRegression::degree | ( | ) | const [inline] |
give the degree of the B-Spline curve.
Definition at line 77 of file STK_BSplineRegression.h.
References degree_.
{ return degree_;}
| Integer const& STK::BSplineRegression::nbControlPoints | ( | ) | const [inline] |
give the number of control points of the B-Spline curves.
Definition at line 82 of file STK_BSplineRegression.h.
References nbControlPoints_.
{ return nbControlPoints_;}
| Matrix const& STK::BSplineRegression::controlPoints | ( | ) | const [inline] |
give the control points.
Definition at line 87 of file STK_BSplineRegression.h.
References controlPoints_.
{ return controlPoints_; }
| Vector const& STK::BSplineRegression::knots | ( | ) | const [inline] |
give the knots.
Definition at line 92 of file STK_BSplineRegression.h.
References coefs_, and STK::BSplineCoefficients::knots().
{ return coefs_.knots(); }

| Matrix const& STK::BSplineRegression::coefficients | ( | ) | const [inline] |
give the computed coefficients of the B-Spline curves.
This is a matrix of size (p_x_->range(), 0:lastControlPoints).
Definition at line 98 of file STK_BSplineRegression.h.
References STK::BSplineCoefficients::coefficients(), and coefs_.
{ return coefs_.coefficients();}

| virtual void STK::BSplineRegression::preRun | ( | ) | [inline, protected, virtual] |
compute the coefficients of the BSpline basis.
This method will be called in the base class IRegression::run()
Reimplemented from STK::IRegression< Matrix, Vector, Vector >.
Definition at line 116 of file STK_BSplineRegression.h.
References coefs_, and STK::BSplineCoefficients::run().
{coefs_.run();}

| void STK::BSplineRegression::regression | ( | ) | [protected, virtual] |
compute the regression function.
This method will be called in the base class IRegression::run() after preRun()
Implements STK::IRegression< Matrix, Vector, Vector >.
Definition at line 66 of file STK_BSplineRegression.cpp.
References STK::BSplineCoefficients::coefficients(), coefs_, controlPoints_, STK::mult(), STK::multLeftTranspose(), and STK::IRegression< Matrix, Vector, Vector >::p_y_.
{
// compute X'X
MatrixSquare prod;
multLeftTranspose(coefs_.coefficients(), prod);
// compute (X'X)^{-1}
GinvSymmetric inv;
inv(prod);
// compute X'Y
Matrix temp;
multLeftTranspose(coefs_.coefficients(), p_y_->asLeaf(), temp);
// compute (X'X)^{-1}X'Y
mult(prod, temp, controlPoints_);
}

| void STK::BSplineRegression::regression | ( | Vector const & | weights | ) | [protected, virtual] |
compute the regression function.
This method will be called in the base class IRegression::run(weights) after preRun()
| weights | the weights of the samples |
Implements STK::IRegression< Matrix, Vector, Vector >.
Definition at line 85 of file STK_BSplineRegression.cpp.
References STK::BSplineCoefficients::coefficients(), coefs_, controlPoints_, STK::mult(), STK::IRegression< Matrix, Vector, Vector >::p_y_, and STK::weightedMultLeftTranspose().
{
// compute X'X
MatrixSquare* prod = weightedMultLeftTranspose(coefs_.coefficients(), weights);
// compute (X'X)^{-1}
GinvSymmetric inv;
inv(prod);
// compute X'Y
Matrix* temp = weightedMultLeftTranspose(coefs_.coefficients(), p_y_->asLeaf(), weights);
// compute (X'X)^{-1}X'Y
mult(*prod, *temp, controlPoints_);
// remove temporary storages
delete temp;
delete prod;
}

| void STK::BSplineRegression::prediction | ( | ) | [protected, virtual] |
Compute the predicted outputs by the regression function.
This method will be called in the base class IRegression::run() after preRun()
Implements STK::IRegression< Matrix, Vector, Vector >.
Definition at line 105 of file STK_BSplineRegression.cpp.
References STK::BSplineCoefficients::coefficients(), coefs_, controlPoints_, STK::mult(), and STK::IRegression< Matrix, Vector, Vector >::p_predicted_.
{
// create predictions if it does not exist any
if (!p_predicted_) p_predicted_ = new Matrix;
// compute predictions
mult(coefs_.coefficients(), controlPoints_, *p_predicted_);
}

| virtual Integer STK::BSplineRegression::computeNbParameter | ( | ) | const [inline, protected, virtual] |
Compute the number of parameter of the regression function.
Implements STK::IRegression< Matrix, Vector, Vector >.
Definition at line 134 of file STK_BSplineRegression.h.
References controlPoints_, STK::IContainer2D::sizeHo(), and STK::IContainer2D::sizeVe().
{ return controlPoints_.sizeHo() * controlPoints_.sizeVe(); }

Integer STK::BSplineRegression::nbControlPoints_ [protected] |
number of control points of the B-Spline curve.
Definition at line 103 of file STK_BSplineRegression.h.
Referenced by nbControlPoints().
Integer STK::BSplineRegression::degree_ [protected] |
degree of the B_Spline curve
Definition at line 105 of file STK_BSplineRegression.h.
Referenced by degree().
_Kposition STK::BSplineRegression::position_ [protected] |
method of position of the knots of the B-Spline curve
Definition at line 107 of file STK_BSplineRegression.h.
BSplineCoefficients STK::BSplineRegression::coefs_ [protected] |
Coefficients of the regression matrix.
Definition at line 109 of file STK_BSplineRegression.h.
Referenced by coefficients(), knots(), prediction(), preRun(), and regression().
Matrix STK::BSplineRegression::controlPoints_ [protected] |
Estimated control points of the B-Spline curve.
Definition at line 111 of file STK_BSplineRegression.h.
Referenced by computeNbParameter(), controlPoints(), prediction(), and regression().