pymc-devs / pymc2

THIS IS THE **OLD** PYMC PROJECT (VERSION 2). PLEASE USE PYMC INSTEAD:
http://pymc-devs.github.com/pymc/
Other
879 stars 229 forks source link

pymc container generates many (seemingly irrelevant) deterministic parents and children #134

Open emad2 opened 8 years ago

emad2 commented 8 years ago

I have a Bayesian network and to model it I am using containers. I have been trying to make sure that the parents/children connections are correct before I proceed, and I noticed that when using containers, pymc generates many deterministic variables that I have not defined myself. To see this, you can run the example in tutorial:

N = 10
x_0 = pymc.Normal('x_0', mu=0, tau=1)

x = np.empty(N, dtype=object)
x[0] = x_0

for i in range(1, N):
     x[i] = pymc.Normal('x_%i' % i, mu=x[i-1], tau=1)

@pymc.observed
def y(value=1, mu=x, tau=100):
    return pymc.normal_like(value, np.sum(mu**2), tau)

and then type x[0].children I see children of the form

pymc.PyMCObjects.Deterministic '(x_0_le_x_2)' at 0x11df54ef0

which I cannot justify. Is this normal? Would I get the same results if I fit a model but don't use containers?

fonnesbeck commented 8 years ago

I cannot reproduce this. I get the following:

In [3]: x[0].children
Out[3]: 
{<pymc.distributions.new_dist_class.<locals>.new_class 'x_1' at 0x1045db0f0>,
 <pymc.PyMCObjects.Stochastic 'y' at 0x118cc3518>}

which is expected.

emad2 commented 8 years ago

I narrowed down the problem to Spyder (the IDE that comes with Anaconda). When I run the code in ipython console of spyder, I get the behavior. When I run it in python environment directly from terminal, everything is fine.