STK++ 1.0
STK::BSplineRegression Class Reference

Compute a BSpline, multivalued, regression function using BSpline basis. More...

#include <STK_BSplineRegression.h>

Inheritance diagram for STK::BSplineRegression:
Collaboration diagram for STK::BSplineRegression:

List of all members.

Public Member Functions

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

Detailed Description

Compute a BSpline, multivalued, regression function using BSpline basis.

Definition at line 51 of file STK_BSplineRegression.h.


Member Typedef Documentation


Constructor & Destructor Documentation

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

Constructor.

Parameters:
p_yd-dimensional array of output to fit
p_xuni-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 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]

virtual destructor.

Definition at line 62 of file STK_BSplineRegression.cpp.

{}

Member Function Documentation

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

give the degree of the B-Spline curve.

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

Returns:
the number of control points of the B-Spline curve

Definition at line 82 of file STK_BSplineRegression.h.

References nbControlPoints_.

    { return nbControlPoints_;}
Matrix const& STK::BSplineRegression::controlPoints ( ) const [inline]

give the control points.

Returns:
the control points of the B-Spline curve

Definition at line 87 of file STK_BSplineRegression.h.

References controlPoints_.

    { return controlPoints_; }
Vector const& STK::BSplineRegression::knots ( ) const [inline]

give the knots.

Returns:
the knots of the B-Spline curve

Definition at line 92 of file STK_BSplineRegression.h.

References coefs_, and STK::BSplineCoefficients::knots().

    { return coefs_.knots(); }

Here is the call graph for this function:

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

Returns:
the coefficients of the B-Spline curve

Definition at line 98 of file STK_BSplineRegression.h.

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

    { return coefs_.coefficients();}

Here is the call graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

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

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

Here is the call graph for this function:

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

Here is the call graph for this function:

virtual Integer STK::BSplineRegression::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, 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(); }

Here is the call graph for this function:


Member Data Documentation

number of control points of the B-Spline curve.

Definition at line 103 of file STK_BSplineRegression.h.

Referenced by nbControlPoints().

degree of the B_Spline curve

Definition at line 105 of file STK_BSplineRegression.h.

Referenced by degree().

method of position of the knots of the B-Spline curve

Definition at line 107 of file STK_BSplineRegression.h.

Coefficients of the regression matrix.

Definition at line 109 of file STK_BSplineRegression.h.

Referenced by coefficients(), knots(), prediction(), preRun(), and regression().

Estimated control points of the B-Spline curve.

Definition at line 111 of file STK_BSplineRegression.h.

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


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