Dirichlet dirichlet = new Dirichlet (new double[] { 1, 1, 1, 1 });
FactorGraph mdl = new FactorGraph (vars);
for (int i = 0; i < length - 1; i++) {
Multinomial m = dirichlet.randomMultinomial (r);
double[] probs = m.getValues ();
mdl.addFactor (vars[i], vars[i + 1], probs);
}
return mdl;
}