I am trying to create the following
sampling_dist = pm.NormalMixture(name,w=[0.5,0.5],mu=[muRV,0.0],sd=[sigma,4.0], observed=sample)
…but when I try to do this, I get a type error from my
sd argument. That
sd argument is a list with a random variable and a float in it.
The error happens because when creating this object, pyMC3 tries to parse the
sd argument (in
get_tau_sd()), which blows up because that argument is a list, not a singleton.
This looks like a bona fide bug to me, from reviewing the code on GitHub, but I’m not a Python expert.
So if this isn’t me doing something completely wrong, I’d appreciate someone letting me know so I can report it as a bug to the maintainers.
I’ve looked at the standard examples, and they seem to have the means and standard deviations they pass to
NormalMixture either be a random variable that has a shape – so is only implicitly a vector of values – or a function of a pair of such values – so again only implicitly a vector of values. In both cases the value of the keyword argument looks to python like a singleton, so doesn’t trigger the error I see.s
This is really a problem for me, because I was trying to use the
NormalMixture because the simple
Mixture didn’t work for me for a different reason (see my other question).
If anyone has a work-around, I would be very grateful!
PyMC3 use theano as the computational engine, so if you have input type error, casting the input to theano variable usually is the first thing to try.
Something like below should work
sampling_dist = pm.NormalMixture(
Thank you very much! I will be testing this out soon, but wanted to respond immediately to say how grateful I am for your help!
My sources for learning PyMC3 don’t really explain theano at all, so this is a very big help.