47 const std::vector<T>& x,
48 const std::vector<T>& y,
67 bool use_scaling,
Vector_double& p, std::string& info,
int& warning );
81 double RTLoHi,
double HalfWidth,
double dt,
Vector_double& pInit );
108 const std::vector<T>& y,
116 for (
unsigned n=0;
n<x.size();++
n) {
122 m=(T)(((T)x.size()*sum_xy-sum_x*sum_y)/((T)x.size()*sum_xx-sum_x*sum_x));
123 c=(T)((sum_y-m*sum_x)/(T)x.size());
125 for (
unsigned n=0;
n<x.size();++
n) {
126 error += (y[
n]-(m*x[
n]+c)) * (y[
n]-(m*x[
n]+c));
std::vector< double > Vector_double
StfnumDll stfnum::storedFunc initLinFunc()
initializes a linear function
T linFit(const std::vector< T > &x, const std::vector< T > &y, T &m, T &c)
Performs a linear fit.
StfnumDll double base(enum stfnum::baseline_method method, double &var, const std::vector< double > &data, std::size_t llb, std::size_t ulb)
Calculate the average of all sampling points between and including llb and ulb.
StfnumDll double peak(const std::vector< double > &data, double base, std::size_t llp, std::size_t ulp, int pM, stfnum::direction, double &maxT)
Find the peak value of data between llp and ulp.
double flin(double x, const Vector_double &p)
Linear function.
StfnumDll Vector_double LM_default_opts()
Return default LM options.
Vector_double get_scale(Vector_double &data, double oldx)
Compute and perform normalisation.
double StfnumDll lmFit(const Vector_double &data, double dt, const stfnum::storedFunc &fitFunc, const Vector_double &opts, bool use_scaling, Vector_double &p, std::string &info, int &warning)
Uses the Levenberg-Marquardt algorithm to perform a non-linear least-squares fit.
void flin_init(const Vector_double &data, double base, double peak, double RTLoHi, double HalfWidth, double dt, Vector_double &pInit)
Dummy function to be passed to stfnum::storedFunc for linear functions.
#define StfnumDll
Defines dll export or import functions for libstfnum on Windows.
Function used for least-squares fitting.