locked
problem with inference RRS feed

  • Question

  • hello everyone,

    i built bayesian network using an array of variables like this:

    public Variable<int>[] _variables;

    all the dependencies are wrote in with the 'setTo' and 'case' command. an example:

                                using (Variable.Case(_variables[i], j))
                                    _variables[k].SetTo(Variable.Discrete(new double[] {0.3,0.2,0.5}));

    my problem is:

    when i'm calling the InferenceEngine and trying to get the distribution of a variable which depend on variables that bigger than it a failure is occur. and example may be that variable number 1 in the array depend on variable number 6 and 11 in the array of the variables.

    an example of and exception:

    "compliationFailedException was caught"

    "int var10 is used before it is assigned to in"

    where var10 is just a name i used with this code: _variables[i] = Variable.New<int>().Named("Var" + i);

    why is that? and how i can fix this problem?

    thanks.


    • Edited by nhasidi Tuesday, April 21, 2015 11:03 PM
    Tuesday, April 21, 2015 10:47 PM

All replies

  • You will need to provide more details about the code.
    Tuesday, April 21, 2015 11:07 PM
    Owner
  • Variable.New simply allocates a variable, it does not assign to it.  The error message wants you to provide a distribution for a variable before you can use it.  In other words, if you view the model as a sampler, when you sample a variable you must have already sampled its parents.
    Wednesday, April 22, 2015 8:47 AM
    Owner