PolynomialFit.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2008 by Paul Demorest
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9#ifndef __Pulsar_PolynomialFit_h
10#define __Pulsar_PolynomialFit_h
11
12#include "Estimate.h"
13#include "Reference.h"
14
15
18
19public:
20
23
25 virtual ~PolynomialFit ();
26
28 void reset();
29
31 void set_degree(int n) { ndeg=n; calcd=false; }
32
34 int get_degree() { return ndeg; }
35
37 void add_data(double x, Estimate<double> y);
38
40 void compute();
41
43 double evaluate(double x);
44
46 double evaluate_deriv(double x);
47
49 double evaluate_integ(double x0, double x1);
50
52 double evaluate_moment(double x0, double x1, int n);
53
55 double get_rchi2();
56
59
60protected:
61
63 std::vector<double> x;
64
66 std::vector< Estimate<double> > y;
67
69 int ndeg;
70
72 double x_avg;
73
75 double chi2;
76
78 bool calcd;
79
81 std::vector< Estimate<double> > coeffs;
82
84 bool check_range(double x);
85
86private:
87
88};
89
90#endif
void set_degree(int n)
Set the degree of the fit.
Definition PolynomialFit.h:31
std::vector< Estimate< double > > y
The y values/errors for the fit.
Definition PolynomialFit.h:66
double evaluate(double x)
Evaluate the fit solution at the given x.
Definition PolynomialFit.C:56
double chi2
The fit chi2.
Definition PolynomialFit.h:75
PolynomialFit()
Default constructor.
Definition PolynomialFit.C:16
int ndeg
Number of polynomial degrees (1=linear, 2=quadratic, etc)
Definition PolynomialFit.h:69
void reset()
Clear all current data, results.
Definition PolynomialFit.C:27
std::vector< Estimate< double > > coeffs
The fitted coeffs.
Definition PolynomialFit.h:81
double get_rchi2()
Get the reduced chi2 of the fit.
Definition PolynomialFit.C:140
double evaluate_integ(double x0, double x1)
Integrate the fit solution between x0 and x1.
Definition PolynomialFit.C:100
std::vector< double > x
The x values for the fit.
Definition PolynomialFit.h:63
Estimate< double > get_coeff(int n)
Get the nth degree fitted polynomial coeff and error.
Definition PolynomialFit.C:148
virtual ~PolynomialFit()
Destructor.
Definition PolynomialFit.C:23
double evaluate_deriv(double x)
Evaluate the fit solution's derivative at the given x.
Definition PolynomialFit.C:78
double evaluate_moment(double x0, double x1, int n)
Integrate x^n * y(x) over the specified range.
Definition PolynomialFit.C:109
int get_degree()
Get the current degree.
Definition PolynomialFit.h:34
void compute()
Compute the fit using current data.
Definition PolynomialFit.C:156
bool calcd
Has the fit been calculated?
Definition PolynomialFit.h:78
void add_data(double x, Estimate< double > y)
Add a data point.
Definition PolynomialFit.C:49
bool check_range(double x)
Check if a requested x val is in the fit range.
Definition PolynomialFit.C:35
double x_avg
Avg x value.
Definition PolynomialFit.h:72
Manages Reference::To references to the instance.
Definition ReferenceAble.h:35

Generated using doxygen 1.14.0