Hi pymc Comunity,
I’d like to do posterior predictive checks on a DensityDist.
I’m implementing a random method for the custom DensityDist distribution, however, the ‘random’ values produced are conditional on other observed data. How can I get this data into the random() method? Maybe something to do with the point input?
I have a simplified version on my code below, where a value (next_epoch) is sampled categorically, conditioned on another value (current_epoch)
There is no FreeRV in your model call ‘current_epoch’ - that’s why it complains.
How about casting current_epoch to theano shared variable and just use it like in the logp: trans_p = trans_baserate[current_epoch, :]?
Seems a little hacky using a variable from the parent scope, but it works
Further, I had to call .eval() on the shared current_epoch in the random() function, as the random function should be using numpy arrays and not theano tensors.
File "/home/bdyetton/PSleep/src/modeling/sleep_stage_models.py", line 208, in _random
current_epoch_values = draw_values(current_epoch_shared)
File "/home/bdyetton/anaconda3/envs/psleep/lib/python3.7/site-packages/pymc3/distributions/distribution.py", line 283, in draw_values
params = dict(enumerate(params))
File "/home/bdyetton/anaconda3/envs/psleep/lib/python3.7/site-packages/theano/tensor/var.py", line 628, in __iter__
for i in xrange(theano.tensor.basic.get_vector_length(self)):
File "/home/bdyetton/anaconda3/envs/psleep/lib/python3.7/site-packages/theano/tensor/basic.py", line 4828, in get_vector_length
raise ValueError("length not known: %s" % msg)
ValueError: length not known: <TensorType(int64, vector)> [id A]
Giving a size input to draw values does not help either.