gslmm::linear< 1 > Class Template Reference
[Function Fit (1 and multi-dimensional)]

#include <linear.hh>

Inheritance diagram for gslmm::linear< 1 >:

Inheritance graph
[legend]
Collaboration diagram for gslmm::linear< 1 >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<>
class gslmm::linear< 1 >

Class template to do $ \chi^2$ fits to experimental data using linear combinations of functions.

The data may be weighted or unweighted. For weighted data the functions compute the best fit parameters and their associated covariance matrix. For unweighted data the covariance matrix is estimated from the scatter of the points, giving a variance-covariance matrix.

This class can be used to perform least-squares fits to a straight line model without a constant term, $ Y = c_1 X$. For weighted data the best-fit is found by minimizing the weighted sum of squared residuals, $ \chi^2$,

\[ \chi^2 = \sum_i w_i (y_i - c_1 x_i)^2 \]

for the parameter $ c_1$. For unweighted data the sum is computed with $ w_i = 1$.


Public Types

typedef basic_linear::data_type data_type
typedef std::pair< data_type,
data_type
return_type

Public Member Functions

 linear ()
virtual ~linear ()
bool fit (const std::vector< data_type > &x, const std::vector< data_type > &y)
bool fit (const std::vector< data_type > &x, const std::vector< data_type > &y, const std::vector< data_type > &w)
return_type eval (const data_type &x)

Private Member Functions

void store (data_type p0, data_type c00)


Member Typedef Documentation

typedef basic_linear::data_type gslmm::linear< 1 >::data_type
 

data type

typedef std::pair<data_type,data_type> gslmm::linear< 1 >::return_type
 

evaluate type


Constructor & Destructor Documentation

gslmm::linear< 1 >::linear  )  [inline]
 

ctor

virtual gslmm::linear< 1 >::~linear  )  [inline, virtual]
 

dtor


Member Function Documentation

return_type gslmm::linear< 1 >::eval const data_type x  )  [inline]
 

This function uses the best-fit linear regression coefficients and their estimated covariance to compute the fitted function $ Y$ and its standard deviation for the model $ Y = c_0 + c_1 X$ at the point $ X$.

Parameters:
x point to evaluate the fit at
Returns:
A pair of values. The first being the computed $ Y$, the second the standard diviaton on the value

bool gslmm::linear< 1 >::fit const std::vector< data_type > &  x,
const std::vector< data_type > &  y,
const std::vector< data_type > &  w
[inline]
 

Perform the fit.

Parameters:
x The independet variable data points
w Weights
y The dependent variable data points
Returns:
true on success

bool gslmm::linear< 1 >::fit const std::vector< data_type > &  x,
const std::vector< data_type > &  y
[inline]
 

Perform the fit.

Parameters:
x The independet variable data points
y The dependent variable data points
Returns:
true on success

void gslmm::linear< 1 >::store data_type  p0,
data_type  c00
[inline, private]
 

Store result of fit.

Parameters:
p0 Parameter
c00 Covariance


The documentation for this class was generated from the following file:
Top of page Last update Tue May 9 10:11:31 2006
Christian Holm
Created by DoxyGen 1.4.6