pymc-devs/pymc — Issue #84: Masked TruncatedNormal
Author: mamaceneil
Created: 2012-01-17 20:46:04+00:00
State: open

I can't seem to pass a masked_array for mu into the TruncatedNormal; Normal works fine - is this a bug?

# E.G.

from pymc import *
from numpy import ma, array

x = array([1,2,-999])
x1 = ma.masked_array(x,mask=x==-999)

y = array([-999,2,4])
y1 = ma.masked_array(y,mask=y==-999)

Normal('Yi',mu=x1,tau=0.01,value=y1,observed=T)
#Out[10]:

# VS:

TruncatedNormal('Yi',mu=x1,tau=0.01,a=0,b=100,value=y1,observed=T)

"""
In [11]: TruncatedNormal('Yi',mu=x1,tau=0.01,a=0,b=100,value=y1,observed=T)
---------------------------------------------------------------------------
ZeroProbability Traceback (most recent call last)
/Volumes/ma_macneil/Documents/Current_work/AIMS_survey_impacts/rates_pymc/ in ()
----> 1 TruncatedNormal('Yi',mu=x1,tau=0.01,a=0,b=100,value=y1,observed=T)

/Users/amac/Downloads/pymc-devs-pymc-5b2d924/pymc/distributions.pyc in __init__(self, *args, **kwds)
266 random = debug_wrapper(random)
267 else:
--> 268 Stochastic.__init__(self, logp=logp, random=random, logp_partial_gradients = logp_partial_gradients, dtype=dtype, **arg_dict_out)
269
270 new_class.__name__ = name

/Users/amac/Downloads/pymc-devs-pymc-5b2d924/pymc/PyMCObjects.pyc in __init__(self, logp, doc, name, parents, random, trace, value, dtype, rseed, observed, cache_depth, plot, verbose, isdata, check_logp, logp_partial_gradients)
700 if check_logp:
701 # Check initial value

--> 702 if not isinstance(self.logp, float):
703 raise ValueError, "Stochastic " + self.__name__ + "'s initial log-probability is %s, should be a float." %self.logp.__repr__()
704

/Users/amac/Downloads/pymc-devs-pymc-5b2d924/pymc/PyMCObjects.pyc in get_logp(self)
832 raise ZeroProbability, self.errmsg + "\nValue: %s\nParents' values:%s" % (self._value, self._parents.value)
833 else:
--> 834 raise ZeroProbability, self.errmsg
835
836 return logp

ZeroProbability: Stochastic Yi's value is outside its support,
or it forbids its parents' current values.
"""