When we have a VariableArray, and each element comes from a different prior, how can we implement it?
If all elements have the same prior (called xPrior for example) the code is like this:
VariableArray<double> x = Variable.Array<double>(xRange).Named("x");
x[xRange] = Variable<double>.Random(xPrior).ForEach(xRange);
But what if the prior is different for different elements?
Can I initialize priors separately? Not all comming from the same distribution?
I wrote this code but I got an error since ObservedValue cannot be derived from an array element (but from the array itself).
VariableArray<double> x = Variable.Array<double>(xRange).Named("x");
VariableArray<double> means = Variable.Observed(new double[] { 0, 5 }, xRange);
VariableArray<double> precs = Variable.Observed(new double[] { 0, 1 }, xRange);
x[xRange] = Variable<double>.Random(Gaussian.FromMeanAndPrecision(means[xRange].ObservedValue, precs[xRange].ObservedValue)).ForEach(xRange);
Is there any way to handle this? Or I should just switch to C# arrays to handle this?