This example shows how to use the EMAlg class.
#include <iostream>
#include <fstream>
#include <string>
int main() {
infprops.
set(
"verbose", (
size_t)1 );
infprops.
set(
"updates",
string(
"HUGIN") );
ifstream estream( "sprinkler.tab" );
cout <<
"Number of samples: " << e.
nrSamples() << endl;
ifstream emstream( "sprinkler.em" );
EMAlg em(e, *inf, emstream);
cout <<
"Iteration " << em.
Iterations() <<
" likelihood: " << l <<endl;
}
cout << endl << "True factor graph:" << endl << "##################" << endl;
cout.precision(12);
cout << SprinklerNetwork;
cout << endl << "Learned factor graph:" << endl << "#####################" << endl;
cout.precision(12);
delete inf;
return 0;
}