pymc-devs / pymc2

THIS IS THE **OLD** PYMC PROJECT (VERSION 2). PLEASE USE PYMC INSTEAD:
http://pymc-devs.github.com/pymc/
Other
879 stars 229 forks source link

Doc Issue affecting DiscreteUniform #135

Closed CarloGraziani closed 7 years ago

CarloGraziani commented 7 years ago

Hello. Thanks for a great and useful package.

The documentation for the DiscreteUniform distribution at https://pymc-devs.github.io/pymc/distributions.html states that

P(x|lower,upper) = 1/(upper-lower)

as well as that the int x is lower <= x <= upper. This contradicts the example of creation of a Stochastic via the decorator, in https://pymc-devs.github.io/pymc/modelbuilding.html, wherein we have

return -np.log(t_h - t_l + 1)

which would correspond to P(x|lower,upper) = 1/(upper-lower+1).

The latter is obviously correct, and also corresponds to what the function duniform_like() does in flib.f. So this is purely a doc issue, causing worry, but not error. For the sake of clarity, I'd suggest that the docs also state explicitly that upper and lower are int -- at the moment their type is not stated.

fonnesbeck commented 7 years ago

The former is the uniform PDF for the continuous case, whereas the latter is the log-PMF for the discrete case, so both are correct!

CarloGraziani commented 7 years ago

Um no. The DiscreteUniform distribution takes int x. It says so right in the doc:

x : [int] lower≤x≤upper

So while the described PDF is for the continuous case, it is misapplied to the distribution that is supposedly described by the doc. And it in fact does not correspond to what the code in flib.f does.

fonnesbeck commented 7 years ago

I see what you mean now. I will fix it.