ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
gsl::fit Namespace Reference

This namespace gives access to all the gsl_fit functions. More...

Functions

int linear (double const *x, size_t const xstride, double const *y, size_t const ystride, size_t const n, double *c0, double *c1, double *cov00, double *cov01, double *cov11, double *sumsq)
 C++ version of gsl_fit_linear(). More...
 
int wlinear (double const *x, size_t const xstride, double const *w, size_t const wstride, double const *y, size_t const ystride, size_t const n, double *c0, double *c1, double *cov00, double *cov01, double *cov11, double *chisq)
 C++ version of gsl_fit_wlinear(). More...
 
int linear_est (double const x, double const c0, double const c1, double const cov00, double const cov01, double const cov11, double *y, double *y_err)
 C++ version of gsl_fit_linear_est(). More...
 
int mul (double const *x, size_t const xstride, double const *y, size_t const ystride, size_t const n, double *c1, double *cov11, double *sumsq)
 C++ version of gsl_fit_mul(). More...
 
int wmul (double const *x, size_t const xstride, double const *w, size_t const wstride, double const *y, size_t const ystride, size_t const n, double *c1, double *cov11, double *chisq)
 C++ version of gsl_fit_wmul(). More...
 
int mul_est (double const x, double const c1, double const cov11, double *y, double *y_err)
 C++ version of gsl_fit_mul_est(). More...
 
int linear (double const *x, double const *y, size_t const n, double *c0, double *c1, double *cov00, double *cov01, double *cov11, double *sumsq)
 C++ version of gsl_fit_linear(). More...
 
int wlinear (double const *x, double const *w, double const *y, size_t const n, double *c0, double *c1, double *cov00, double *cov01, double *cov11, double *chisq)
 C++ version of gsl_fit_wlinear(). More...
 
int mul (double const *x, double const *y, size_t const n, double *c1, double *cov11, double *sumsq)
 C++ version of gsl_fit_mul(). More...
 
int wmul (double const *x, double const *w, double const *y, size_t const n, double *c1, double *cov11, double *chisq)
 C++ version of gsl_fit_wmul(). More...
 
template<typename ARRAY >
int linear (ARRAY const &x, ARRAY const &y, double &c0, double &c1, double &cov00, double &cov01, double &cov11, double &sumsq, size_t const n=0)
 C++ version of gsl_fit_linear() for std::vector and the like. More...
 
template<typename ARRAY >
int wlinear (ARRAY const &x, ARRAY const &w, ARRAY const &y, double &c0, double &c1, double &cov00, double &cov01, double &cov11, double &chisq, size_t const n=0)
 C++ version of gsl_fit_wlinear() for std::vector and the like. More...
 
template<typename ARRAY >
int mul (ARRAY const &x, ARRAY const &y, double &c1, double &cov11, double &sumsq, size_t const n=0)
 C++ version of gsl_fit_mul() for std::vector and the like. More...
 
template<typename ARRAY >
int wmul (ARRAY const &x, ARRAY const &w, ARRAY const &y, double &c1, double &cov11, double &chisq, size_t const n=0)
 C++ version of gsl_fit_wmul() for std::vector and the like. More...
 

Detailed Description

This namespace gives access to all the gsl_fit functions.

Since the GNU Scientific library does not have functions for univariate regression that work directly with vectors, we add some here. You can use gsl::vector objects with non-unit strides in the overloaded functions.

Function Documentation

◆ linear() [1/3]

template<typename ARRAY >
int gsl::fit::linear ( ARRAY const &  x,
ARRAY const &  y,
double &  c0,
double &  c1,
double &  cov00,
double &  cov01,
double &  cov11,
double &  sumsq,
size_t const  n = 0 
)
inline

C++ version of gsl_fit_linear() for std::vector and the like.

Univariate regression.

Parameters
xA vector of values of the independent variable.
yA vector of values of the dependent variable.
c0First (constant coefficient) (return value).
c1Second coefficient (return value).
cov00First variance in covariance matrix (return value).
cov01Covariance from covariance matrix (return value).
cov11Second variance in covariance matrix (return value).
sumsqResidual sum of squares (return value).
nNumber of elements in vectors of dependent and independent variables (default of zero is substituted with vector size).
Returns
Error code on failure.

Definition at line 400 of file fit.hpp.

References linear(), and gsl::rstat::n().

◆ linear() [2/3]

int gsl::fit::linear ( double const *  x,
double const *  y,
size_t const  n,
double *  c0,
double *  c1,
double *  cov00,
double *  cov01,
double *  cov11,
double *  sumsq 
)
inline

C++ version of gsl_fit_linear().

Univariate regression.

Parameters
xAn array of values of the independent variable.
yAn array of values of the dependent variable.
nNumber of elements in arrays of dependent and independent variables.
c0First (constant coefficient) (return value).
c1Second coefficient (return value).
cov00First variance in covariance matrix (return value).
cov01Covariance from covariance matrix (return value).
cov11Second variance in covariance matrix (return value).
sumsqResidual sum of squares (return value).
Returns
Error code on failure.

Definition at line 161 of file fit.hpp.

References gsl::rstat::n().

◆ linear() [3/3]

int gsl::fit::linear ( double const *  x,
size_t const  xstride,
double const *  y,
size_t const  ystride,
size_t const  n,
double *  c0,
double *  c1,
double *  cov00,
double *  cov01,
double *  cov11,
double *  sumsq 
)
inline

C++ version of gsl_fit_linear().

Univariate regression.

Parameters
xAn array of values of the independent variable.
xstrideStride of the independent variable array
yAn array of values of the dependent variable.
ystrideStride of the dependent variable
nNumber of elements in arrays of dependent and independent variables.
c0First (constant coefficient) (return value).
c1Second coefficient (return value).
cov00First variance in covariance matrix (return value).
cov01Covariance from covariance matrix (return value).
cov11Second variance in covariance matrix (return value).
sumsqResidual sum of squares (return value).
Returns
Error code on failure.

Definition at line 51 of file fit.hpp.

References gsl::rstat::n().

Referenced by linear().

◆ linear_est()

int gsl::fit::linear_est ( double const  x,
double const  c0,
double const  c1,
double const  cov00,
double const  cov01,
double const  cov11,
double *  y,
double *  y_err 
)
inline

C++ version of gsl_fit_linear_est().

Estimate fit from regression model.

Parameters
xValue of the independent variable.
c0First coefficient.
c1Second coefficient.
cov00First variance from covariance matrix.
cov01Covariance from covariance matrix.
cov11Second variance from covariance matrix.
yPredicted value of the dependent variable.
y_errEstimated standard deviation in y.
Returns
Error code on failure.

Definition at line 94 of file fit.hpp.

◆ mul() [1/3]

template<typename ARRAY >
int gsl::fit::mul ( ARRAY const &  x,
ARRAY const &  y,
double &  c1,
double &  cov11,
double &  sumsq,
size_t const  n = 0 
)
inline

C++ version of gsl_fit_mul() for std::vector and the like.

Univariate regression with no constant.

Parameters
xA vector of values of the independent variable.
yA vector of values of the dependent variable.
c1Coefficient (return value).
cov11Variance (return value)
sumsqResidual sum of squares (return value).
nNumber of elements in vectors of dependent and independent variables (default of zero is substituted with vector size).
Returns
Error code on failure.

Definition at line 464 of file fit.hpp.

References mul(), and gsl::rstat::n().

◆ mul() [2/3]

int gsl::fit::mul ( double const *  x,
double const *  y,
size_t const  n,
double *  c1,
double *  cov11,
double *  sumsq 
)
inline

C++ version of gsl_fit_mul().

Univariate regression with no constant.

Parameters
xAn array of values of the independent variable.
yAn array of values of the dependent variable.
nNumber of elements in arrays of dependent and independent variables.
c1Coefficient (return value).
cov11Variance (return value)
sumsqResidual sum of squares (return value).
Returns
Error code on failure.

Definition at line 196 of file fit.hpp.

References gsl::rstat::n().

◆ mul() [3/3]

int gsl::fit::mul ( double const *  x,
size_t const  xstride,
double const *  y,
size_t const  ystride,
size_t const  n,
double *  c1,
double *  cov11,
double *  sumsq 
)
inline

C++ version of gsl_fit_mul().

Univariate regression with no constant.

Parameters
xAn array of values of the independent variable.
xstrideStride of the independent variable array
yAn array of values of the dependent variable.
ystrideStride of the dependent variable
nNumber of elements in arrays of dependent and independent variables.
c1Coefficient (return value).
cov11Variance (return value)
sumsqResidual sum of squares (return value).
Returns
Error code on failure.

Definition at line 110 of file fit.hpp.

References gsl::rstat::n().

Referenced by mul().

◆ mul_est()

int gsl::fit::mul_est ( double const  x,
double const  c1,
double const  cov11,
double *  y,
double *  y_err 
)
inline

C++ version of gsl_fit_mul_est().

Estimate fit from regression model.

Parameters
xValue of the independent variable.
c1Coefficient.
cov11Covariance.
yPredicted value of the dependent variable.
y_errEstimated standard deviation in y.
Returns
Error code on failure.

Definition at line 143 of file fit.hpp.

◆ wlinear() [1/3]

template<typename ARRAY >
int gsl::fit::wlinear ( ARRAY const &  x,
ARRAY const &  w,
ARRAY const &  y,
double &  c0,
double &  c1,
double &  cov00,
double &  cov01,
double &  cov11,
double &  chisq,
size_t const  n = 0 
)
inline

C++ version of gsl_fit_wlinear() for std::vector and the like.

Univariate weighted regression.

Parameters
xA vector of values of the independent variable.
wA vector of weights for the data.
yA vector of values of the dependent variable.
c0First (constant coefficient) (return value).
c1Second coefficient (return value).
cov00First variance in covariance matrix (return value).
cov01Covariance from covariance matrix (return value).
cov11Second variance in covariance matrix (return value).
chisqWeighted residual sum of squares (return value).
nNumber of elements in vectors of dependent and independent variables (default of zero is substituted with vector size).
Returns
Error code on failure.

Definition at line 432 of file fit.hpp.

References gsl::ran::chisq(), gsl::rstat::n(), and wlinear().

◆ wlinear() [2/3]

int gsl::fit::wlinear ( double const *  x,
double const *  w,
double const *  y,
size_t const  n,
double *  c0,
double *  c1,
double *  cov00,
double *  cov01,
double *  cov11,
double *  chisq 
)
inline

C++ version of gsl_fit_wlinear().

Univariate weighted regression.

Parameters
xAn array of values of the independent variable.
wAn array of weights for the data.
yAn array of values of the dependent variable.
nNumber of elements in arrays of dependent and independent variables.
c0First (constant coefficient) (return value).
c1Second coefficient (return value).
cov00First variance in covariance matrix (return value).
cov01Covariance from covariance matrix (return value).
cov11Second variance in covariance matrix (return value).
chisqWeighted residual sum of squares (return value).
Returns
Error code on failure.

Definition at line 181 of file fit.hpp.

References gsl::ran::chisq(), and gsl::rstat::n().

◆ wlinear() [3/3]

int gsl::fit::wlinear ( double const *  x,
size_t const  xstride,
double const *  w,
size_t const  wstride,
double const *  y,
size_t const  ystride,
size_t const  n,
double *  c0,
double *  c1,
double *  cov00,
double *  cov01,
double *  cov11,
double *  chisq 
)
inline

C++ version of gsl_fit_wlinear().

Univariate weighted regression.

Parameters
xAn array of values of the independent variable.
xstrideStride of the independent variable array
wAn array of weights for the data.
wstrideStride of the array of weights
yAn array of values of the dependent variable.
ystrideStride of the dependent variable
nNumber of elements in arrays of dependent and independent variables.
c0First (constant coefficient) (return value).
c1Second coefficient (return value).
cov00First variance in covariance matrix (return value).
cov01Covariance from covariance matrix (return value).
cov11Second variance in covariance matrix (return value).
chisqWeighted residual sum of squares (return value).
Returns
Error code on failure.

Definition at line 74 of file fit.hpp.

References gsl::ran::chisq(), and gsl::rstat::n().

Referenced by wlinear().

◆ wmul() [1/3]

template<typename ARRAY >
int gsl::fit::wmul ( ARRAY const &  x,
ARRAY const &  w,
ARRAY const &  y,
double &  c1,
double &  cov11,
double &  chisq,
size_t const  n = 0 
)
inline

C++ version of gsl_fit_wmul() for std::vector and the like.

Weighted univariate regression with no constant.

Parameters
xA vector of values of the independent variable.
wA vector of weights for the data.
yA vector of values of the dependent variable.
c1Coefficient (return value).
cov11Variance (return value)
chisqWeighted residual sum of squares (return value).
nNumber of elements in vectors of dependent and independent variables (default of zero is substituted with vector size).
Returns
Error code on failure.

Definition at line 491 of file fit.hpp.

References gsl::ran::chisq(), gsl::rstat::n(), and wmul().

◆ wmul() [2/3]

int gsl::fit::wmul ( double const *  x,
double const *  w,
double const *  y,
size_t const  n,
double *  c1,
double *  cov11,
double *  chisq 
)
inline

C++ version of gsl_fit_wmul().

Weighted univariate regression with no constant.

Parameters
xAn array of values of the independent variable.
wAn array of weights for the data.
yAn array of values of the dependent variable.
nNumber of elements in arrays of dependent and independent variables.
c1Coefficient (return value).
cov11Variance (return value)
chisqWeighted residual sum of squares (return value).
Returns
Error code on failure.

Definition at line 211 of file fit.hpp.

References gsl::ran::chisq(), and gsl::rstat::n().

◆ wmul() [3/3]

int gsl::fit::wmul ( double const *  x,
size_t const  xstride,
double const *  w,
size_t const  wstride,
double const *  y,
size_t const  ystride,
size_t const  n,
double *  c1,
double *  cov11,
double *  chisq 
)
inline

C++ version of gsl_fit_wmul().

Weighted univariate regression with no constant.

Parameters
xAn array of values of the independent variable.
xstrideStride of the independent variable array
wAn array of weights for the data.
wstrideStride of the array of weights
yAn array of values of the dependent variable.
ystrideStride of the dependent variable
nNumber of elements in arrays of dependent and independent variables.
c1Coefficient (return value).
cov11Variance (return value)
chisqWeighted residual sum of squares (return value).
Returns
Error code on failure.

Definition at line 128 of file fit.hpp.

References gsl::ran::chisq(), and gsl::rstat::n().

Referenced by wmul().