STK++ 1.0
STK::AdditiveBSplineRegression Class Reference

Compute an additive BSpline, multivalued, regression function using BSpline basis. More...

#include <STK_AdditiveBSplineRegression.h>

Inheritance diagram for STK::AdditiveBSplineRegression:
Collaboration diagram for STK::AdditiveBSplineRegression:

List of all members.

Public Member Functions

 AdditiveBSplineRegression (Matrix const *p_y, Matrix const *p_x, Integer const &nbControlPoints, Integer const &degree=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

Detailed Description

Compute an additive BSpline, multivalued, regression function using BSpline basis.

Definition at line 49 of file STK_AdditiveBSplineRegression.h.


Member Typedef Documentation


Constructor & Destructor Documentation

STK::AdditiveBSplineRegression::AdditiveBSplineRegression ( Matrix const *  p_y,
Matrix const *  p_x,
Integer const &  nbControlPoints,
Integer const &  degree = 3,
_Kposition const &  position = BSplineCoefficients::uniform_ 
)

Constructor.

Parameters:
p_yp-dimensional array of output to fit
p_xd-dimensional array of predictor
nbControlPointsnumber of control points of the spline
degreedegree of the BSpline basis
positionposition 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]

virtual destructor.

Definition at line 71 of file STK_AdditiveBSplineRegression.cpp.

{}

Member Function Documentation

Integer const& STK::AdditiveBSplineRegression::degree ( ) const [inline]

give the degree of the B-Spline curves.

Returns:
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.

Returns:
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.

Returns:
the control points of the B-Spline curves

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).

Returns:
the coefficients of the B-Spline curve

Definition at line 91 of file STK_AdditiveBSplineRegression.h.

References STK::AdditiveBSplineCoefficients::coefficients(), and coefs_.

    { return coefs_.coefficients();}

Here is the call graph for this function:

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());
  }
}

Here is the call graph for this function:

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_);
}

Here is the call graph for this function:

void STK::AdditiveBSplineRegression::regression ( Vector const &  weights) [protected, virtual]

compute the regression function.

Parameters:
weightsweights 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;
}

Here is the call graph for this function:

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_);
}

Here is the call graph for this function:

virtual Integer STK::AdditiveBSplineRegression::computeNbParameter ( ) const [inline, protected, virtual]

Compute the number of parameter of the regression function.

Returns:
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(); }

Here is the call graph for this function:


Member Data Documentation

number of control points of the B-Spline curve.

Definition at line 96 of file STK_AdditiveBSplineRegression.h.

Referenced by nbControlPoints(), and preRun().

degree of the B_Spline curve

Definition at line 98 of file STK_AdditiveBSplineRegression.h.

Referenced by degree(), and preRun().

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().

Estimated control points of the B-Spline curve.

Definition at line 104 of file STK_AdditiveBSplineRegression.h.

Referenced by computeNbParameter(), controlPoints(), prediction(), and regression().


The documentation for this class was generated from the following files: