Variable v1, Variable v2)
{
int max1 = v1.getNumOutcomes();
int max2 = v2.getNumOutcomes();
Matrix phi = new Matrixn(new int[]{max1, max2});
for (int i = 0; i < v1.getNumOutcomes(); i++) {
for (int j = 0; j < v2.getNumOutcomes(); j++) {
phi.setValue(new int[]{i, j}, r.nextDouble ()); // rescale(r.nextDouble()));
}
}
return new TableFactor
(new Variable[]{v1, v2}, phi);
}