Custom Generation of a Discrete Distribution based on Random Variables<p>Hello, </p>
<p>I have a graphical model where there is a node, in a plate, that has a discrete distribution defined by a custom generation procedure. Specifically, the procedure generates a truncated geometric with some extra mass at x = 0. It takes three parameters
(n, gamma and lambda) where n controls the dimension of the discrete distribution and is always observed (but n varies based on plate id).</p>
<p>Does Infer.net support writing such a generation procedure for the discrete distribution? it tried writing a custom factor but ran into a problem: the framework doesn't like that the nodes have distributions whose dimensions vary based on the value of a
random variable (even if the variable is observed).</p>
<p>Thanks,</p>
<p>Mohammmad</p>
<br/>© 2009 Microsoft Corporation. All rights reserved.Mon, 14 Oct 2013 07:44:16 Z2e6f769c-426f-4e26-b248-ec9641851c08- https://social.microsoft.com/Forums/en-US/2e6f769c-426f-4e26-b248-ec9641851c08/custom-generation-of-a-discrete-distribution-based-on-random-variables?forum=infer.net#2e6f769c-426f-4e26-b248-ec9641851c08https://social.microsoft.com/Forums/en-US/2e6f769c-426f-4e26-b248-ec9641851c08/custom-generation-of-a-discrete-distribution-based-on-random-variables?forum=infer.net#2e6f769c-426f-4e26-b248-ec9641851c08MohammadKhajahhttps://social.microsoft.com:443/profile/mohammadkhajah/?type=forumCustom Generation of a Discrete Distribution based on Random Variables<p>Hello, </p>
<p>I have a graphical model where there is a node, in a plate, that has a discrete distribution defined by a custom generation procedure. Specifically, the procedure generates a truncated geometric with some extra mass at x = 0. It takes three parameters
(n, gamma and lambda) where n controls the dimension of the discrete distribution and is always observed (but n varies based on plate id).</p>
<p>Does Infer.net support writing such a generation procedure for the discrete distribution? it tried writing a custom factor but ran into a problem: the framework doesn't like that the nodes have distributions whose dimensions vary based on the value of a
random variable (even if the variable is observed).</p>
<p>Thanks,</p>
<p>Mohammmad</p>
<br/>Wed, 09 Oct 2013 15:23:12 Z2013-10-09T15:23:12Z
- https://social.microsoft.com/Forums/en-US/2e6f769c-426f-4e26-b248-ec9641851c08/custom-generation-of-a-discrete-distribution-based-on-random-variables?forum=infer.net#701d31f1-4baa-437f-96a4-516a461bfb76https://social.microsoft.com/Forums/en-US/2e6f769c-426f-4e26-b248-ec9641851c08/custom-generation-of-a-discrete-distribution-based-on-random-variables?forum=infer.net#701d31f1-4baa-437f-96a4-516a461bfb76Tom Minkahttps://social.microsoft.com:443/profile/tom%20minka/?type=forumCustom Generation of a Discrete Distribution based on Random Variables<p>You will need to use a custom factor for this. The tricky part is telling the framework what the cardinality of the output is. You can do it by providing two definitions of the output: the first one only defines the cardinality (and
is never used) while the second one provides the intended definition. Here is an example using Binomial:</p>
<pre class="prettyprint"> var x = Variable.New<int>();
var b = Variable.Observed(false);
using (Variable.If(b))
{
x.SetTo(Variable.DiscreteUniform(n + 1));
}
using (Variable.IfNot(b))
{
x.SetTo(Variable.Binomial(n, 0.1));
}
</pre>
This causes the cardinality of x to be (n+1) which is the correct cardinality for the output of Binomial. Since the factor you are trying to implement is already a mixture (due to the extra mass at zero), you could use the above construction to represent
the mixture and accomplish two things at once. The first definition of x would be a Discrete whose probs represent a point mass at zero, and whose cardinality is n.<br/>Thu, 10 Oct 2013 10:36:31 Z2013-10-10T10:36:31Z