Distributions.jl icon indicating copy to clipboard operation
Distributions.jl copied to clipboard

Polya-Gamma distribution

Open theogf opened this issue 4 years ago • 2 comments

Hey! This issue is basically a revival of #685, I now have a clean implementation of the Polya-Gamma distribution in https://github.com/theogf/AugmentedGaussianProcesses.jl but I would be happy to move it to Distributions.jl. Most of the code is based on/translated from https://github.com/slinderman/pypolyagamma which I can pretend to understand fully. Would you be open to a PR?

theogf avatar Nov 25 '21 16:11 theogf

I would be open to it. I don't agree with the sentiment in the original issue that it is a Bayesian "thing" and therefore should not be added - I think Distributions should be agnostic to the frequentist vs Bayesian debate and support reasonably common and useful distributions.

The main problem I see here though is that both the Python package and BayesLogit (which it seems to be based on) use GPLv3. I'm not a lawyer but AFAIK this implies that if you copied or translated the implementation from one of these packages then the Julia resulting Julia code has to use the GPLv3 or an equivalent license as well. However, the MIT license is not compatible with GPLv3. I'm not sure if it would be possible to use the GPLv3 license only for the translated files but from the discussion in e.g. https://github.com/JuliaStats/Distributions.jl/pull/254 it seems this is not the case.

Hence as far as I understand (please correct me if I'm wrong), if you translated the code from the Python package then AugmentedGaussianProcesses has to use the GPLv3 or an equivalent license, and it can't be added to Distributions since it would not be compatible with the MIT license. The best approach would be a clean room implementation, possibly based on some paper, by someone who hasn't looked at the GPLv3 code.

devmotion avatar Nov 25 '21 20:11 devmotion

Thanks for the advice! Technically, I implemented the algorithm 1, 2, 3 from this paper (same authors etc), "Bayesian inference for logistic models using Pólya-Gamma latent variables' https://arxiv.org/abs/1205.0310, just at some point, to sample from a truncated inverse Gaussian, I really copied the code for it, since it is not really explained in the paper. One could argue that all this stuff just come from Devroye though :sweat_smile: Additionally, I went beyond a 1 to 1 translation and really adapted the code to be more Julian.

theogf avatar Nov 25 '21 21:11 theogf