|
STK++ 1.0
|
Compute an additive BSpline, multivalued, regression function using BSpline basis. More...
#include <STK_AdditiveBSplineRegression.h>


Public Member Functions | |
| AdditiveBSplineRegression (Matrix const *p_y, Matrix const *p_x, Integer const &nbControlPoints, Integer const °ree=3, _Kposition const &position=BSplineCoefficients::uniform_) | |
| Constructor. | |
| virtual | ~AdditiveBSplineRegression () |
| virtual destructor. | |
| Integer const & | degree () const |
| give the degree of the B-Spline curves. | |
| Integer const & | nbControlPoints () const |
| give the number of control points of the B-Spline curves. | |
| Matrix const & | controlPoints () const |
| give the control points. | |
| 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 | |
| AdditiveBSplineCoefficients | coefs_ |
| Coefficients of the regression matrix. | |
| Matrix | controlPoints_ |
| Estimated control points of the B-Spline curve. | |
Private Types | |
| typedef BSplineCoefficients::KnotsPosition | _Kposition |
Compute an additive BSpline, multivalued, regression function using BSpline basis.
Definition at line 49 of file STK_AdditiveBSplineRegression.h.
typedef BSplineCoefficients::KnotsPosition STK::AdditiveBSplineRegression::_Kposition [private] |
Definition at line 52 of file STK_AdditiveBSplineRegression.h.
| STK::AdditiveBSplineRegression::AdditiveBSplineRegression | ( | Matrix const * | p_y, |
| Matrix const * | p_x, | ||
| Integer const & | nbControlPoints, | ||
| Integer const & | degree = 3, |
||
| _Kposition const & | position = BSplineCoefficients::uniform_ |
||
| ) |
Constructor.
| p_y | p-dimensional array of output to fit |
| p_x | d-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 56 of file STK_AdditiveBSplineRegression.cpp.
: IRegression<Matrix, Matrix, Vector>(p_y, p_x)
, nbControlPoints_(nbControlPoints)
, degree_(degree)
, position_(position)
, coefs_(p_x, nbControlPoints_, degree_, position_)
, controlPoints_()
{ }
| STK::AdditiveBSplineRegression::~AdditiveBSplineRegression | ( | ) | [virtual] |
| Integer const& STK::AdditiveBSplineRegression::degree | ( | ) | const [inline] |
give the degree of the B-Spline curves.
Definition at line 75 of file STK_AdditiveBSplineRegression.h.
References degree_.
{ return degree_;}
| Integer const& STK::AdditiveBSplineRegression::nbControlPoints | ( | ) | const [inline] |
give the number of control points of the B-Spline curves.
Definition at line 80 of file STK_AdditiveBSplineRegression.h.
References nbControlPoints_.
{ return nbControlPoints_;}
| Matrix const& STK::AdditiveBSplineRegression::controlPoints | ( | ) | const [inline] |
give the control points.
Definition at line 85 of file STK_AdditiveBSplineRegression.h.
References controlPoints_.
{ return controlPoints_; }
| Matrix const& STK::AdditiveBSplineRegression::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 91 of file STK_AdditiveBSplineRegression.h.
References STK::AdditiveBSplineCoefficients::coefficients(), and coefs_.
{ return coefs_.coefficients();}

| void STK::AdditiveBSplineRegression::preRun | ( | ) | [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, Matrix, Vector >.
Definition at line 78 of file STK_AdditiveBSplineRegression.cpp.
References coefs_, degree_, STK::IRunnerBase::error(), nbControlPoints_, STK::IRegression< Matrix, Matrix, Vector >::p_x_, position_, STK::AdditiveBSplineCoefficients::run(), and STK::AdditiveBSplineCoefficients::setData().
{
coefs_.setData(p_x_, nbControlPoints_, degree_, position_);
if (!coefs_.run())
{
throw runtime_error(coefs_.error());
}
}

| void STK::AdditiveBSplineRegression::regression | ( | ) | [protected, virtual] |
compute the regression function.
Implements STK::IRegression< Matrix, Matrix, Vector >.
Definition at line 88 of file STK_AdditiveBSplineRegression.cpp.
References STK::AdditiveBSplineCoefficients::coefficients(), coefs_, controlPoints_, STK::mult(), STK::multLeftTranspose(), and STK::IRegression< Matrix, Matrix, 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::AdditiveBSplineRegression::regression | ( | Vector const & | weights | ) | [protected, virtual] |
compute the regression function.
| weights | weights of the samples |
Implements STK::IRegression< Matrix, Matrix, Vector >.
Definition at line 109 of file STK_AdditiveBSplineRegression.cpp.
References STK::AdditiveBSplineCoefficients::coefficients(), coefs_, controlPoints_, STK::mult(), STK::IRegression< Matrix, Matrix, 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::AdditiveBSplineRegression::prediction | ( | ) | [protected, virtual] |
Compute the predicted outputs by the regression function.
Implements STK::IRegression< Matrix, Matrix, Vector >.
Definition at line 129 of file STK_AdditiveBSplineRegression.cpp.
References STK::AdditiveBSplineCoefficients::coefficients(), coefs_, controlPoints_, STK::mult(), and STK::IRegression< Matrix, Matrix, Vector >::p_predicted_.
{
// remove existing predictions if any (should not be the case)
if (!p_predicted_) p_predicted_ = new Matrix;
// compute predictions
mult(coefs_.coefficients(), controlPoints_, *p_predicted_);
}

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

number of control points of the B-Spline curve.
Definition at line 96 of file STK_AdditiveBSplineRegression.h.
Referenced by nbControlPoints(), and preRun().
Integer STK::AdditiveBSplineRegression::degree_ [protected] |
degree of the B_Spline curve
Definition at line 98 of file STK_AdditiveBSplineRegression.h.
_Kposition STK::AdditiveBSplineRegression::position_ [protected] |
method of position of the knots of the B-Spline curve
Definition at line 100 of file STK_AdditiveBSplineRegression.h.
Referenced by preRun().
Coefficients of the regression matrix.
Definition at line 102 of file STK_AdditiveBSplineRegression.h.
Referenced by coefficients(), prediction(), preRun(), and regression().
Matrix STK::AdditiveBSplineRegression::controlPoints_ [protected] |
Estimated control points of the B-Spline curve.
Definition at line 104 of file STK_AdditiveBSplineRegression.h.
Referenced by computeNbParameter(), controlPoints(), prediction(), and regression().