IMP logo
IMP Reference Guide  2.20.2
The Integrative Modeling Platform
statistics/ChiSquareMetric.h
Go to the documentation of this file.
1 /**
2  * \file IMP/statistics/ChiSquareMetric.h
3  * \brief Chi2 Metric
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPSTATISTICS_CHI_SQUARE_METRIC_H
9 #define IMPSTATISTICS_CHI_SQUARE_METRIC_H
10 
11 #include <IMP/statistics/statistics_config.h>
12 #include <IMP/statistics/Metric.h>
13 #include <IMP/object_macros.h>
14 #include <IMP/types.h>
15 #include <IMP/Pointer.h>
16 
17 IMPSTATISTICS_BEGIN_NAMESPACE
18 
19 //! Compute the distance between two configurations using chi2
20 /** Each configurations is defined by a list of data points and
21  * a list of standard deviations. The distance between the two
22  * configurations is defined as the chi2.
23  */
24 class IMPSTATISTICSEXPORT ChiSquareMetric : public Metric {
25 
26  //! list of weights
27  Floats weight_;
28  //! list of experimental data points
29  Floats data_exp_;
30  //! list of normalizations
31  Floats norm_;
32  //! type of constructor
33  int constr_type_;
34  //! list of lists of data points
35  std::vector<Floats> datas_;
36  //! list of lists of experimental data points
37  std::vector<Floats> stddev_;
38 
39  //! get chi2 between two configurations
40  double get_chisquare(unsigned i, unsigned j) const;
41  //! get scalar chi2 between two configurations
42  double get_scalarchisquare(unsigned i, unsigned j) const;
43 
44  public:
45  ChiSquareMetric(Floats data_exp, int constr_type = 0);
46  //! add a configuration, defined by a list of data points,
47  //! a list of standard deviations, and one weight.
48  void add_configuration(Floats data, Floats stddev, double weight = 1.0);
49  //! get the list of data points for the i-th configuration
50  Floats get_data(unsigned i) const;
51  //! get the list of standard deviations for the i-th configuration
52  Floats get_standard_deviation(unsigned i) const;
53  //! get the weight for the i-th configuration
54  double do_get_weight(unsigned i) const override;
55  //! get chi2 from experimental data for the i-th configuration
56  double get_chi_square_experimental(unsigned i) const;
57 
58  double get_distance(unsigned int i, unsigned int j) const override;
59  unsigned int get_number_of_items() const override;
60 
62 };
63 
64 IMPSTATISTICS_END_NAMESPACE
65 
66 #endif /* IMPSTATISTICS_CHI_SQUARE_METRIC_H */
Helper macros for implementing IMP Objects.
Basic types used by IMP.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
virtual double do_get_weight(unsigned int i) const
By default return 1.0.
Definition: Metric.h:29
Compute the distance between two configurations using chi2.
A nullptr-initialized pointer to an IMP Object.
Cluster sets of points.
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.
Store data to be clustered for distance metric based algorithms.
Definition: Metric.h:25