Hello, I have only recently got familiar with PyMC3. I have been trying to use the potential function to impose constraints on a distribution. I was trying to run the following piece of code:
*import pymc3 as pm*
*import numpy as np*
*with pm.Model() as model:*
* 2D_binary_vectors = pm.Bernoulli('2D_binary_vectors', p = 0.7, shape=2)*
* exclude00 = pm.Potential('exclude00', pm.math.switch(pm.math.sum(2D_binary_vectors) >= 1 , 0, -np.inf))*
* trace = pm.sample(20000)*
*trace [2D_binary_vectors]*
I get output like this:
**array([[1, 1],**
** [1, 1],**
** [1, 1],**
** ...,**
** [0, 1],**
** [0, 1],**
** [1, 1]], dtype=int64)**
Which is expected! There are no [0,0] which is what I expect the potential would do. However, if I decrease the value of the parameter in the Bernoulli prior to p = 0.5, the same code gives me nothing but [0,0]. So, for the following code:
**with pm.Model() as model:**
** 2D_binary_vectors = pm.Bernoulli('2D_binary_vectors', p = 0.5, shape=2)**
** exclude00 = pm.Potential('exclude00', pm.math.switch(pm.math.sum(2D_binary_vectors) >= 1 , 0, -np.inf))**
** trace = pm.sample(20000)**
**trace [2D_binary_vectors]**
I get:
**array([[0, 0],**
** [0, 0],**
** [0, 0],**
** ...,**
** [0, 0],**
** [0, 0],**
** [0, 0]], dtype=int64)**
I get nothing but [0,0], which was the only thing I was trying to exclude. I donât understand whatâs going on here.