5

In PyMC2, there are methods random() and value() to generate a random value, and get the current value of random variables. Is there any way to do the same in PyMC3?

p = pm.Dirichlet('p', theta=np.array([1., 1., 1.]))
p.random()
p.value
ahmethungari
  • 2,089
  • 4
  • 19
  • 21

1 Answers1

1

Not quite yet, but there is an almost done PR here: https://github.com/pymc-devs/pymc3/pull/784

There is no real .value as we store state outside of the RVs now.

twiecki
  • 1,316
  • 8
  • 11
  • The reason I ask is mostly for debugging. When I define a distribution, I want to see what values it generates without running the entire simulation. Any idea on how to do it? – ahmethungari Jul 27 '15 at 15:47
  • The new random() method should give you that, no? Or do you just want to evaluate the PDF? – twiecki Jul 29 '15 at 07:32
  • Yes it should, but as "twiecki" said it is not ready. I thought there might be some other ways around while we wait it to be ready. – ahmethungari Jul 30 '15 at 14:43
  • You could plot the PDF. Something like np.exp([dist.logp(val) for val in np.linspace(-3, 3, 100)]) – twiecki Jul 31 '15 at 15:18
  • @twiecki, is there a way to do this (p.value) now? – Shobhit Apr 10 '16 at 02:18
  • No, but there is .random() now. We store state (i.e. value) outside of the model now rather than attach it to the RV. What are you trying to do? – twiecki Apr 11 '16 at 16:27