00001 #define __cplusplus__ 00002 #ifndef __HMRF__ 00003 #define __HMRF__ 00004 00005 #include<iostream> 00006 #include<istream> 00007 #include<fstream> 00008 #include<string> 00009 #include<vector> 00010 #include<sstream> 00011 #include <cmath> 00012 00013 00014 #include <Seg_Model.hpp> 00015 #include <Spatial_Data.hpp> 00016 #include <Neighborhood_System.hpp> 00017 #include <MRF.hpp> 00018 #include <Distribution.hpp> 00019 #include <Diag_Normal.hpp> 00020 #include <Normal.hpp> 00021 #include <HighDim_Normal.hpp> 00022 #include <Laplace.hpp> 00023 00024 00025 using namespace std; 00026 00027 00037 class HMRF : public Seg_Model{ 00038 00039 protected : 00040 00042 Random_Field *RF; 00043 00044 public : 00045 00047 HMRF(); 00049 HMRF(Neighborhood_System *nhs); 00051 HMRF(uint k, uint dim , Neighborhood_System *nhs); 00053 HMRF( Random_Field *rf , vector<Distribution *> const & distrib); 00055 HMRF( Random_Field *rf , vector<Diag_Normal *> const & distrib); 00057 HMRF( Random_Field *rf , vector<Normal *> const & distrib); 00059 HMRF( Random_Field *rf , vector<Laplace *> const & distrib); 00061 HMRF( Random_Field *rf , vector<HighDim_Normal *> const & distrib); 00062 00064 ~HMRF(); 00065 00067 uint Get_N(); 00068 00070 double LogLikelihood(Spatial_Data *spatd); 00072 double BIC(Spatial_Data *spatd ); 00074 double ICL(Spatial_Data *spatd ); 00075 00077 double H(uint i, uint k, vector<uint> const & z); 00079 double Hmf(uint i, uint k); 00080 00081 void Compute_PGmf(vector<double> & P_G); 00083 void Set_Zmf( vector<double> const & z ); 00085 void Set_Zmf( vector<double> const & z , uint i); 00087 void Get_Zmf( vector<double> & z ); 00088 00090 void Simulate(Data *dat, uint gibbs_sampler_nbiter ); 00092 void Simulate(Data *dat, double grad_tol ); 00093 00095 void Set_Gradient(double step, double tol, uint maxiter); 00096 00098 void Estimate_MRF(vector<double> const & tik); 00100 void Estimate(Spatial_Data *spatd, vector<double> const & tik); 00101 00103 double Completed_LogLikelihood(Spatial_Data *spatd, vector<double> const & tik); 00104 00106 double PLIC(Spatial_Data *spatd, vector<uint> const & Z_ICM); 00107 00109 uint Degrees_Of_Freedom() ; 00110 00112 void Info(); 00114 void ReadFromFile(string filename); 00116 void WriteToFile(string filename); 00117 00118 }; 00119 00120 00121 #endif