9#ifndef __Pulsar_SplineSmooth_h
10#define __Pulsar_SplineSmooth_h
12#include "ReferenceAble.h"
34 double get_alpha ()
const {
return alpha; }
37 void unload (
const std::string&)
const;
39 void load (
const std::string&);
44 double evaluate (
const std::vector<double>& xval);
64 void fit (
const std::vector< double >& data_x,
65 const std::vector< Estimate<double> >& data_y);
67 double evaluate (
double x);
78 SplineSmooth2D (
const std::string& json) :
SplineSmooth (json) {}
80 void fit (
const std::vector< std::pair<double,double> >& data_x,
81 const std::vector< Estimate<double> >& data_y);
83 double evaluate (
const std::pair<double,double>& );
95 class CrossValidatedSmooth2D
100 double validation_fraction;
102 SplineSmooth2D* spline;
104 double iqr_threshold;
105 unsigned nflagged_iqr;
107 double gof_step_threshold;
108 unsigned nflagged_gof;
110 std::vector<double> gof_tot;
111 std::vector<unsigned> gof_count;
113 std::string gof_filename;
114 std::ofstream* gof_out;
118 CrossValidatedSmooth2D ();
120 void set_gof_filename (
const std::string& name) { gof_filename = name; }
122 void set_spline (SplineSmooth2D* _spline) { spline = _spline; }
127 unsigned get_npartition ()
const {
return npartition; }
132 double get_validation_fraction ()
const {
return validation_fraction; }
137 double get_iqr_threshold ()
const {
return iqr_threshold; }
142 double get_gof_step_threshold ()
const {
return gof_step_threshold; }
145 void fit ( std::vector< std::pair<double,double> >& data_x,
148 void remove_iqr_outliers
149 ( std::vector< std::pair<double,double> >& x,
152 unsigned get_nflagged_iqr ()
const {
return nflagged_iqr; }
154 void find_optimal_smoothing_factor
155 (
const std::vector< std::pair<double,double> >& dat_x,
156 const std::vector< Estimate<double> >& dat_y );
158 void remove_gof_outliers
159 ( std::vector< std::pair<double,double> >& x,
160 std::vector< Estimate<double> >& y );
162 unsigned get_nflagged_gof ()
const {
return nflagged_gof; }
165 double get_mean_gof (
const std::vector< std::pair<double,double> >& data_x,
166 const std::vector< Estimate<double> >& data_y);
170 const std::vector< std::pair<double,double> >& data_x,
171 const std::vector< Estimate<double> >& data_y);
175 class BootstrapUncertainty2D
178 SplineSmooth2D* spline;
182 BootstrapUncertainty2D ();
184 void set_spline (SplineSmooth2D* _spline) { spline = _spline; }
186 void get_uncertainty (
const std::vector< std::pair<double,double> >& data_x,
187 std::vector< Estimate<double> >& data_y);
void set_validation_fraction(double f)
Set the fraction of data reserved for validation.
Definition SplineSmooth.h:131
void set_iqr_threshold(double t)
Set the multiple of IQR used to implement Tukey's fence outlier detection.
Definition SplineSmooth.h:136
void set_gof_step_threshold(double s)
Set the goodness-of-fit step threshold.
Definition SplineSmooth.h:141
void fit(std::vector< std::pair< double, double > > &data_x, std::vector< Estimate< double > > &data_y)
Fit spline to data using current configuration.
Definition CrossValidatedSmooth2D.C:80
void set_npartition(unsigned m)
Set the number of cross-validation iterations, m.
Definition SplineSmooth.h:126
double get_mean_gof(const std::vector< std::pair< double, double > > &data_x, const std::vector< Estimate< double > > &data_y)
Return the mean goodness-of-fit for the current smoothing.
Definition CrossValidatedSmooth2D.C:394
Base class of penalized splines (p-spline) for smoothing.
Definition SplineSmooth.h:20
void load(const std::string &)
Load spline from specified filename.
Definition SplineSmooth.C:134
double evaluate(const std::vector< double > &xval)
evaluate method used by derived types
Definition SplineSmooth.C:168
~SplineSmooth()
Destructor.
Definition SplineSmooth.C:73
void set_alpha(double _alpha)
Set the smoothing factor.
Definition SplineSmooth.h:33
SplineSmooth()
Constructor.
Definition SplineSmooth.C:32
void new_spline(const std::vector< T > &data_x, const std::vector< Estimate< double > > &data_y)
constructor used by derived types
Definition SplineSmooth.C:90
void unload(const std::string &) const
Unload spline to specified filename.
Definition SplineSmooth.C:124
Defines the PSRCHIVE library.
Definition CalSource.h:17