1 #ifndef CONVERGENCE_CHECK_H 2 #define CONVERGENCE_CHECK_H 4 #include <blitz/array.h> 29 int Number_divergent,
double D_sigma_sq,
30 double D_sigma_sq_scaled,
double Chisq_apriori,
31 double Chisq_measured,
double Chisq_apriori_fc,
32 double Chisq_measured_fc)
144 void print(std::ostream& Os)
const;
151 const blitz::Array<double, 1>& Residual_cov_diag)
const 152 {
return sum(Residual * Residual / Residual_cov_diag) / Residual.rows(); }
159 {
return sqrt(sum(Residual * Residual) / Residual.rows()); }
166 const blitz::Array<double, 1>& Rad_measure)
const 168 (sum(Rad_measure) / Rad_measure.rows()); }
211 virtual void convergence_check(
const FitStatistic& fit_stat_last,
214 bool& convergence_failed,
216 bool& step_diverged) = 0;
229 virtual void evaluate_quality(
FitStatistic& fit_stat_last,
230 const blitz::Array<double, 1>& Residual,
231 const blitz::Array<double, 1>& Residual_cov_diag) = 0;
246 virtual void print(std::ostream& Os)
const { Os <<
"ConvergenceCheck";}
void to_stream(std::ostream &os) const
Dump data to a stream.
void from_stream(std::istream &is)
Load data from a stream.
This class holds various parameters describing how good of a fit we have.
FitStatistic(bool Fit_succeeded, OUTCOME Outcome, int Number_iteration, int Number_divergent, double D_sigma_sq, double D_sigma_sq_scaled, double Chisq_apriori, double Chisq_measured, double Chisq_apriori_fc, double Chisq_measured_fc)
double d_sigma_sq
This is d_sigma_sq, which is the product of the correction to the state vector and the right hand siz...
void print(std::ostream &Os) const
Print to a stream.
std::istream & operator>>(std::istream &Is, ConnorSolver &Solve)
double chisq_measured_fc
Chisq of the residuals of the measurement vs.
FitStatistic()
Default constructor.
This is a Mixin for classes that can be printed.
double gamma2_fc() const
Parameter "gamma2_fc", which is just chisq_apriori_fc + chisq_measured_fc.
double chisq_apriori_fc
Chisq of the X_i vs.
double chisq_measure_norm(const blitz::Array< double, 1 > &Residual, const blitz::Array< double, 1 > &Residual_cov_diag) const
Calculate chisq for given residual and covariance matrix.
int number_divergent
Number of divergent steps.
This class tests for convergence of a Levenberg-Marquardt solver.
bool fit_succeeded
Was the fit successful?
OUTCOME outcome
Flag indicating success of fit, or why fit wasn't succesful.
double d_sigma_sq_scaled
This is d_sigma_sq, scaled by the size of the state vector.
double residual_rel_rms(const blitz::Array< double, 1 > &Residual, const blitz::Array< double, 1 > &Rad_measure) const
Calculate relative root mean squared for given residual.
double residual_abs_rms(const blitz::Array< double, 1 > &Residual) const
Calculate absolute root mean squared for given residual.
virtual void print(std::ostream &Os) const
Print description of object.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
double chisq_measured
Chisq of the residuals of the measurement vs. model prediction.
virtual void initialize_check()
Called before the first iteration, in case there is any setup.
int number_iteration
Number of iterations.
double chisq_apriori
Chisq of the X_i vs. the apriori X value.
virtual ~ConvergenceCheck()
double gamma2() const
Parameter "gamma2", which is just chi2_apriori + chi2_measured.