locked
Why was TransferFaileException thrown? (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • tankbattle posted on 12-09-2009 1:43 AM

    I wrote the following code to get the likelyhood of value 0 for Binomial distribution B(1000, 0.1):

      static void Main(string[] args)
      {
       Variable<int> b1 = Variable.Binomial(1000, 0.1);
       InferenceEngine ie = new InferenceEngine();
       Variable<int> dest = Variable.New<int>();
       dest.ObservedValue = 0;
       Console.WriteLine(ie.Infer(b1 > dest));
       Console.ReadKey();
      }

    and on running, the TransferFailedException was thrown with message:

    ChannelTransform failed with 1 error(s) and 0 warning(s):
      Cannot automatically determine distribution type for variable type 'int': you must specify a arginalPrototype attribute for variable 'vint1'. in int vint1

    Is it possible I missed any initialization work? Thank you in advance!

    Friday, June 3, 2011 5:27 PM

Answers

  • John Guiver replied on 12-09-2009 5:51 AM

    Thanks for bringing this to our attention. If you ever get a message like this, you can explicitly specify a marginal prototype, in this case as follows:

    Variable<int> b1 = Variable.Binomial(1000, 0.1).Attrib(new MarginalPrototype(Discrete.Uniform(1001)));

    Here you need a discrete distribution of size one more than the number of trials in order to represent the probabilities for each possible number of successes.

    John G.

    Friday, June 3, 2011 5:28 PM