BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
LogMetric Class Reference

Implementation of the standard $ \chi^2 $ metric with intensity $I$ and experimental data $D$ being replaced by $ \log_{10} I $ and $\log_{10} D$ accordingly. More...

+ Inheritance diagram for LogMetric:

Public Member Functions

LogMetricclone () const override
 
double computeFromArrays (std::vector< double > sim_data, std::vector< double > exp_data, std::vector< double > uncertainties, std::vector< double > weight_factors) const override
 Computes metric value from data arrays. More...
 
double computeFromArrays (std::vector< double > sim_data, std::vector< double > exp_data, std::vector< double > weight_factors) const override
 Computes metric value from data arrays. More...
 
- Public Member Functions inherited from ObjectiveMetric
 ObjectiveMetric (std::function< double(double)> norm)
 
virtual double compute (const SimDataPair &data_pair, bool use_weights) const
 Computes metric value from SimDataPair object. More...
 
void setNorm (std::function< double(double)> norm)
 
auto norm () const
 Returns a copy of the normalization function used.
 
- Public Member Functions inherited from ICloneable
 ICloneable (const ICloneable &)=delete
 
 ICloneable (ICloneable &&)=default
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py)
 

Detailed Description

Implementation of the standard $ \chi^2 $ metric with intensity $I$ and experimental data $D$ being replaced by $ \log_{10} I $ and $\log_{10} D$ accordingly.

With default L2 norm corresponds to the formula

\[\chi^2 = \sum \frac{(\log_{10} I - log_{10} D)^2 D^2 \ln^2{10}}{\delta_D^2}\]

Definition at line 133 of file ObjectiveMetric.h.

Member Function Documentation

◆ computeFromArrays() [1/2]

double LogMetric::computeFromArrays ( std::vector< double >  sim_data,
std::vector< double >  exp_data,
std::vector< double >  uncertainties,
std::vector< double >  weight_factors 
) const
overridevirtual

Computes metric value from data arrays.

Negative values in exp_data are ignored as well as non-positive weight_factors and uncertainties. All arrays involved in the computation must be of the same size.

Parameters
sim_dataarray with simulated intensities.
exp_dataarray with intensity values obtained from an experiment.
uncertaintiesarray with experimental data uncertainties.
weight_factorsuser-defined weighting factors. Used linearly, no matter which norm is chosen.

Implements ObjectiveMetric.

Definition at line 155 of file ObjectiveMetric.cpp.

◆ computeFromArrays() [2/2]

double LogMetric::computeFromArrays ( std::vector< double >  sim_data,
std::vector< double >  exp_data,
std::vector< double >  weight_factors 
) const
overridevirtual

Computes metric value from data arrays.

Negative values in exp_data are ignored as well as non-positive weight_factors. All arrays involved in the computation must be of the same size.

Parameters
sim_dataarray with simulated intensities.
exp_dataarray with intensity values obtained from an experiment.
weight_factorsuser-defined weighting factors. Used linearly, no matter which norm is chosen.

Implements ObjectiveMetric.

Definition at line 176 of file ObjectiveMetric.cpp.


The documentation for this class was generated from the following files: