Go to the documentation of this file.00001
00002 #ifndef pdf1d_mixture_builder_h_
00003 #define pdf1d_mixture_builder_h_
00004
00005
00006
00007
00008
00009
00010
00011 #include <pdf1d/pdf1d_builder.h>
00012 #include <pdf1d/pdf1d_mixture_builder.h>
00013 #include <pdf1d/pdf1d_mixture.h>
00014 #include <vcl_iosfwd.h>
00015
00016
00017
00018
00019 class pdf1d_mixture_builder : public pdf1d_builder
00020 {
00021 private:
00022 vcl_vector<pdf1d_builder*> builder_;
00023 double min_var_;
00024 int max_its_;
00025
00026
00027 bool weights_fixed_;
00028
00029 void initialise(pdf1d_mixture& model,
00030 const double* data,
00031 const vcl_vector<double>& wts) const;
00032
00033
00034 void e_step(pdf1d_mixture& model,
00035 vcl_vector<vnl_vector<double> >& probs,
00036 const double* data,
00037 const vcl_vector<double>& wts) const;
00038
00039
00040 double m_step(pdf1d_mixture& model,
00041 const vcl_vector<vnl_vector<double> >& probs,
00042 const double* data,
00043 const vcl_vector<double>& wts) const;
00044
00045 void init();
00046 void delete_stuff();
00047 public:
00048
00049
00050 pdf1d_mixture_builder();
00051
00052
00053 pdf1d_mixture_builder(const pdf1d_mixture_builder&);
00054
00055
00056 pdf1d_mixture_builder& operator=(const pdf1d_mixture_builder&);
00057
00058
00059 virtual ~pdf1d_mixture_builder();
00060
00061
00062
00063 void init(pdf1d_builder& builder, int n);
00064
00065
00066 void set_max_iterations(int n);
00067
00068
00069 bool weights_fixed() const { return weights_fixed_; }
00070
00071
00072 void set_weights_fixed(bool b);
00073
00074
00075 virtual pdf1d_pdf* new_model() const;
00076
00077
00078 virtual vcl_string new_model_type() const;
00079
00080
00081 virtual void set_min_var(double min_var);
00082
00083
00084 virtual double min_var() const;
00085
00086
00087
00088
00089 static void calc_mean_and_variance(pdf1d_mixture& model);
00090
00091
00092 virtual void build(pdf1d_pdf& model, double mean) const;
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 virtual void build(pdf1d_pdf& model,
00103 mbl_data_wrapper<double>& data) const;
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 virtual void weighted_build(pdf1d_pdf& model,
00114 mbl_data_wrapper<double>& data,
00115 const vcl_vector<double>& wts) const;
00116
00117
00118 short version_no() const;
00119
00120
00121 virtual vcl_string is_a() const;
00122
00123
00124 virtual bool is_class(vcl_string const& s) const;
00125
00126
00127 virtual pdf1d_builder* clone() const;
00128
00129
00130 virtual void print_summary(vcl_ostream& os) const;
00131
00132
00133 virtual void b_write(vsl_b_ostream& bfs) const;
00134
00135
00136 virtual void b_read(vsl_b_istream& bfs);
00137 };
00138
00139 #endif // pdf1d_mixture_builder_h_