BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ObjectiveMetric Class Referenceabstract

Base class for metric implementations. More...

+ Inheritance diagram for ObjectiveMetric:

Public Member Functions

 ObjectiveMetric (std::function< double(double)> norm)
 
ObjectiveMetricclone () const override=0
 
virtual double compute (const SimDataPair &data_pair, bool use_weights) const
 Computes metric value from SimDataPair object. More...
 
virtual double computeFromArrays (std::vector< double > sim_data, std::vector< double > exp_data, std::vector< double > uncertainties, std::vector< double > weight_factors) const =0
 Computes metric value from data arrays. More...
 
virtual double computeFromArrays (std::vector< double > sim_data, std::vector< double > exp_data, std::vector< double > weight_factors) const =0
 Computes metric value from data arrays. 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

Base class for metric implementations.

Definition at line 26 of file ObjectiveMetric.h.

Member Function Documentation

◆ compute()

double ObjectiveMetric::compute ( const SimDataPair data_pair,
bool  use_weights 
) const
virtual

Computes metric value from SimDataPair object.

Calls computeFromArrays internally.

Parameters
data_pairSimDataPair object. Can optionally contain data uncertainties
use_weightsboolean, defines if data uncertainties should be taken into account

Reimplemented in RQ4Metric.

Definition at line 61 of file ObjectiveMetric.cpp.

◆ computeFromArrays() [1/2]

virtual double ObjectiveMetric::computeFromArrays ( std::vector< double >  sim_data,
std::vector< double >  exp_data,
std::vector< double >  uncertainties,
std::vector< double >  weight_factors 
) const
pure virtual

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.

Implemented in LogMetric, and Chi2Metric.

◆ computeFromArrays() [2/2]

virtual double ObjectiveMetric::computeFromArrays ( std::vector< double >  sim_data,
std::vector< double >  exp_data,
std::vector< double >  weight_factors 
) const
pure virtual

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.

Implemented in RelativeDifferenceMetric, LogMetric, PoissonLikeMetric, and Chi2Metric.


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