The documentation here states that the following should work:
import pymc as pm
y = pm.Binomial.dist(n=10, p=0.5)
y.logp(4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'TensorVariable' object has no attribute 'logp'. Did you mean: 'log'?
however as you can see, this throws an error. I need to compute the PDF of a random variable within my model - I was hoping to use something like
pdf_at_x = pm.math.exp(random_variable.logp(x))
can someone please let me know the correct way to do this? The documentation is very sparse…
Thanks! This does work. Since in the example above, random_variable is supposed to represent a PDF, could I skip pm.logp() and just call something like
Random variables aren’t PDFs, they’re random variables. pytensor.function([], random_variable) returns draws from that random variable (well not exactly, there’s some missing boilerplate to handle random seeds. Consider pm.compile over pytensor.function when working with RVs).
Anyway, value isn’t an input at all to random_variable.