IMP  2.1.1
The Integrative Modeling Platform
WeightedProfileFitter.h
Go to the documentation of this file.
1 /**
2  * \file saxs/WeightedProfileFitter.h
3  * \brief Fitting of multiple profiles to the experimental one.
4  * The weights of the profiles are computed analytically using
5  * non-negative least squares fitting (NNLS)
6  *
7  * \authors Dina Schneidman
8  * Copyright 2007-2013 IMP Inventors. All rights reserved.
9  *
10  */
11 
12 #ifndef IMPSAXS_WEIGHTED_PROFILE_FITTER_H
13 #define IMPSAXS_WEIGHTED_PROFILE_FITTER_H
14 
15 #include "ProfileFitter.h"
16 #include "ChiScore.h"
17 #include "WeightedFitParameters.h"
18 #include "internal/Diagonal.h"
19 #include "internal/Vector.h"
20 
21 IMPSAXS_BEGIN_NAMESPACE
22 
23 /**
24  Fitting of multiple profiles to the experimental one.
25  The weights of the profiles are computed analytically using
26  non-negative least squares fitting (NNLS).
27 */
28 class IMPSAXSEXPORT WeightedProfileFitter : public ProfileFitter<ChiScore> {
29 
30  public:
31  //! Constructor
32  /**
33  \param[in] exp_profile Experimental profile we want to fit
34  */
35  WeightedProfileFitter(const Profile* exp_profile);
36 
37  //! compute a weighted score that minimizes chi
38  /**
39  it is assumed that the q values of the profiles are the same as
40  the q values of the experimental profile. Use Profile::resample to resample
41  */
42  Float compute_score(const ProfilesTemp& profiles,
43  std::vector<double>& weights= empty_weights_) const;
44 
45  //! fit profiles by optimization of c1/c2 and weights
46  /**
47  it is assumed that the q values of the profiles are the same as
48  the q values of the experimental profile. Use Profile::resample to resample
49  */
50  WeightedFitParameters fit_profile(ProfilesTemp partial_profiles,
51  float min_c1=0.95, float max_c1=1.05,
52  float min_c2=-2.0, float max_c2=4.0,
53  const std::string fit_file_name = "") const;
54 
55  //! write a fit file
56  void write_fit_file(ProfilesTemp partial_profiles,
57  const WeightedFitParameters& fp,
58  const std::string fit_file_name) const;
59 private:
60  WeightedFitParameters search_fit_parameters(
61  ProfilesTemp& partial_profiles,
62  float min_c1, float max_c1, float min_c2, float max_c2,
63  float old_chi, std::vector<double>& weights) const;
64 
65  private:
66  internal::Diagonal W_; // weights matrix
67 
68  // weights matrix multiplied by experimental intensities vector
69  internal::Vector Wb_;
70 
71  // intensities
72  internal::Matrix A_;
73 
74  //default, when weight are not needed
75  static Floats empty_weights_;
76 };
77 
78 IMPSAXS_END_NAMESPACE
79 
80 #endif /* IMPSAXS_WEIGHTED_PROFILE_FITTER_H */
Basic chi score implementation.
a class for fitting two profiles
Copyright 2007-2013 IMP Inventors. All rights reserved.
Float compute_score(const Profile *model_profile, bool use_offset=false, const std::string fit_file_name="") const
compute fit score
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
FitParameters fit_profile(Profile *partial_profile, float min_c1=0.95, float max_c1=1.05, float min_c2=-2.0, float max_c2=4.0, bool use_offset=false, const std::string fit_file_name="") const
fit experimental profile through optimization of c1 and c2 parameters