Hi, I try to create an array of dirichlet distribution with non uniform priors but it wouldn't compile at all with these errors. Please help me. Thanks all.
Error 1 The best overloaded method match for 'MicrosoftResearch.Infer.Models.Variable.Dirichlet(double[])' has some invalid arguments C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\CPT\CPT\Program.cs 38 44 CPT
static void Main(string[] args)
{
Range two = new Range(2).Named("two");
Range five = new Range(5).Named("five");
VariableArray2D<Vector> behaviour = Variable.Array<Vector>(two, five);
double[,][] alpha = new double[,][] { {
new double[]{ 1, 0, 0, 0, 0 },
new double[]{ 2, 1, 0, 0, 0 },
new double[]{ 3, 2, 1, 0, 0 },
new double[]{ 4, 3, 2, 1, 0 },
new double[]{ 5, 4, 3, 2, 1 }
},
new double[]{ 1, 2, 3, 4, 5 },
new double[]{ 0, 1, 2, 3, 4 },
new double[]{ 0, 0, 1, 2, 3 },
new double[]{ 0, 0, 0, 1, 2 },
new double[]{ 0, 0, 0, 0, 1 }
} };
VariableArray2D<double[]> alph = Variable.Constant<double[]>(alpha, two, five).Named("alph");
using (Variable.ForEach(two))
using (Variable.ForEach(five))
behaviour[two, five] = Variable.Dirichlet( alph[two, five] );
}
Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
Hi Freddy
There is no short cut method for Variable.Dirichlet which takes a variable argument. Recommended method is as below which uses the unary ‘Random’ factor. (In addition, it is better to make prior an Observed rather than a Constant, so it doesn’t get compiled into the code – let me know if you need help with that).
John
Dirichlet[,] dir = new Dirichlet[,]
new Dirichlet(new double[]{ 1, 0, 0, 0, 0 }),
new Dirichlet(new double[]{ 2, 1, 0, 0, 0 }),
new Dirichlet(new double[]{ 3, 2, 1, 0, 0 }),
new Dirichlet(new double[]{ 4, 3, 2, 1, 0 }),
new Dirichlet(new double[]{ 5, 4, 3, 2, 1 })
}, {
new Dirichlet(new double[]{ 1, 2, 3, 4, 5 }),
new Dirichlet(new double[]{ 0, 1, 2, 3, 4 }),
new Dirichlet(new double[]{ 0, 0, 1, 2, 3 }),
new Dirichlet(new double[]{ 0, 0, 0, 1, 2 }),
new Dirichlet(new double[]{ 0, 0, 0, 0, 1 })
};
VariableArray2D<Dirichlet> prior = Variable.Constant(dir, two, five).Named("prior");
behaviour[two, five] = Variable.Random<Vector, Dirichlet>(prior[two,five]);