-
-
Notifications
You must be signed in to change notification settings - Fork 2k
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Masked TruncatedNormal #84
Comments
Just updated to the latest git (pymc-devs-pymc-055b94f) with a slightly modified result: E.G. 2In [14]: TruncatedNormal('Yi',mu=x1,tau=0.01,a=0,b=100,value=y1,observed=T)FloatingPointError Traceback (most recent call last) /Library/Python/2.7/site-packages/pymc/distributions.pyc in init(self, _args, *_kwds) /Library/Python/2.7/site-packages/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) /Library/Python/2.7/site-packages/pymc/Node.pyc in init(self, doc, name, parents, cache_depth, trace, dtype, plot, verbose) /Library/Python/2.7/site-packages/pymc/Node.pyc in init(self, doc, name, parents, cache_depth, verbose) --> 111 self.parents = parents /Library/Python/2.7/site-packages/pymc/Node.pyc in _set_parents(self, new_parents) --> 132 self.gen_lazy_function() /Library/Python/2.7/site-packages/pymc/PyMCObjects.pyc in gen_lazy_function(self) /Library/Python/2.7/site-packages/pymc/LazyFunction.so in pymc.LazyFunction.LazyFunction.force_compute() /Library/Python/2.7/site-packages/pymc/distributions.pyc in wrapper(**kwds) /Library/Python/2.7/site-packages/pymc/distributions.pyc in truncated_normal_like(x, mu, tau, a, b) /Library/Python/2.7/site-packages/pymc/utils.pyc in log_difference(lx, ly)
--> 734 diff = ly - lx
FloatingPointError: invalid value encountered in subtract |
Ah I see this might be due to behaviour I didn't understand - the x1 values here are taking on the fill_value from ma and not being updated; is this correct? |
Just getting back to this now. Yes, its only the value that should be masked array, not the parameters. So, the following works:
|
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]: <pymc.distributions.Normal 'Yi' at 0x1100ebfd0>
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.
"""
The text was updated successfully, but these errors were encountered: