Search code examples
pythonprobabilitypymcdirichlet

logp for dirichlet stochastic variable in pymc is coming out to be > 1


As far as I understand, logp should b2 <= 0, else the probability will be > 1 (which is not possible).

Can someone please explain why I am getting such a strange result. I am writing the relevant part of code below.

parameters = pm.Dirichlet('parameters',[1,1,1,1], doc='parameters')
print parameters.value, parameters.logp

I get the following output

[ 0.29402696  0.64604328  0.04713606] 1.79175946923

This is something strange. I have no prior experience using dirichlet random variable in pymc. I just looked up the syntax in documentation and wrote it. I might be wrong, please correct me if so.

Another small problem

No matter how many random values I take, the logprobability doesn't change even though I get different values everytime.


Solution

  • The Dirichlet distribution is a continuous distribution, so its density may be greater than 1. Remember that a continuous density must be nonnegative, and its integral must be 1. But it is not required that the density be less than 1 everywhere.

    About your second question -- my advice is to open a new question to answer that; don't smash two questions into one.