# NC::SpectrumInterpolatorFancy Class Reference

Given a set of reference histograms, interpolate between them. More...

#include <NCSpectrumInterpolator.h>

Inheritance diagram for NC::SpectrumInterpolatorFancy:

List of all members.

## Protected Member Functions

int intintpow (int a, int b) const
Private utility function. Calculates a^b using integer arithmetic.
double doubleintpow (double a, int b) const
Private utility function. Calculates a^b where b is an integer.
virtual TMatrixD FindCoeffs (const std::vector< std::vector< double > > &xs, const std::vector< double > &x) const
Do the bulk of the work.

## Detailed Description

Given a set of reference histograms, interpolate between them.

Consider a curve fit to a set of points by a chi-squared statistic

where the weight accorded to any point varies with .

Let be a linear combination of some basis functions

We want to solve for the that gives the best fit ie for all

Naming the terms we have

and solving for gives

The final result can now be computed.

So the coefficients of all the 's () can be precomputed as they are functions only of .

The calculation is general and works for multidimensional . Because the final combination of the 's is linear and the coefficients can be precomputed we can operate directly over entire histograms.

The functions are chosen to be one-term polynomials, making up the full polynomial. So, we need to compute the full set of possible combinations of powers to raise things to so we know what terms are possible.

Where is the input vector in D-dimensional space and is the matrix of powers. above, pows in the code.

The calculation of the coefficients is achieved in ISpectrumInterpolator::FindCoeffs. is called basis, is mat, is vecPart, is denom and is pows.

The function chosen for is

This has the feature that diverges whenever is any of the 's

This is good in that it forces the fit function to go through that point by giving it infinite weight, but bad in that it causes divide-by-zeros. We detect when is very close to an and in that case construct the coefficient vector by hand so that it picks out the corresponding .

Todo:
Try multiplying up by all the weights, so that, instead of the weight going infinite, it goes to zero on all the other terms. This should prevent divide-by-zero but we may still have problems with the matrix being non-invertible.

Definition at line 183 of file NCSpectrumInterpolator.h.

## Member Function Documentation

 double NC::SpectrumInterpolatorFancy::doubleintpow ( double a, int b ) const [protected]

Private utility function. Calculates a^b where b is an integer.

Definition at line 124 of file NCSpectrumInterpolator.cxx.

00125 {
00126   double ret = 1;
00127   while(b--) ret *= a;
00128   return ret;
00129 }


 virtual TMatrixD NC::SpectrumInterpolatorFancy::FindCoeffs ( const std::vector< std::vector< double > > & xs, const std::vector< double > & x ) const [protected, virtual]

Do the bulk of the work.

Implements NC::ISpectrumInterpolator.

 int NC::SpectrumInterpolatorFancy::intintpow ( int a, int b ) const [protected]

Private utility function. Calculates a^b using integer arithmetic.

Definition at line 116 of file NCSpectrumInterpolator.cxx.

00117 {
00118   int ret = 1;
00119   while(b--) ret *= a;
00120   return ret;
00121 }


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

Generated on 24 Jul 2018 for loon by  1.6.1