BufferedWriter out = new BufferedWriter(new FileWriter(name+".txt"));
int numStates = m.getNumStates();
int numObservations = m.getNumObservations();
double defaultProbability = m.getDefaultProbability();
Quantizer quantizer = m.getQuantizer();
HMM hmm = m.getHMM();
out.write("# numStates:");
out.newLine();
out.write(Integer.toString(numStates));
out.newLine();
out.write("# numObservations:");
out.newLine();
out.write(Integer.toString(numObservations));
out.newLine();
out.write("# defaultProbability:");
out.newLine();
out.write(Double.toString(defaultProbability));
out.newLine();
out.write("# Quantizer: Radius");
out.newLine();
out.write(Double.toString(quantizer.getRadius()));
out.newLine();
out.write("# Quantizer: MAP");
out.newLine();
double[][] map = quantizer.getHashMap();
for(int v=0; v<map.length; v++) {
double[] d = map[v];
out.write(Double.toString(d[0])+", "+Double.toString(d[1])+", "+Double.toString(d[2]));
out.newLine();
}
out.write("# HMM: PI");
out.newLine();
double[] pi = hmm.getPi();
for (int i=0; i<numStates; i++) {
if(i==numStates-1) {
out.write(Double.toString(pi[i]));
out.newLine();
} else {
out.write(Double.toString(pi[i])+", ");
}
}
out.write("# HMM: A");
out.newLine();
double[][] a = hmm.getA();
for(int i=0; i<numStates; i++) {
for(int j=0; j<numStates; j++) {
if(j==numStates-1) {
out.write(Double.toString(a[i][j]));
out.newLine();
} else {
out.write(Double.toString(a[i][j])+", ");
}
}
}
out.write("# HMM: B");
out.newLine();
double[][] b = hmm.getB();
for(int i=0; i<numStates; i++) {
for(int j=0; j<numObservations; j++) {
if(j==numObservations-1) {
out.write(Double.toString(b[i][j]));
out.newLine();