pyro-ppl / pyro

Deep universal probabilistic programming with Python and PyTorch
http://pyro.ai
Apache License 2.0
8.58k stars 987 forks source link

[feature request] Add the Hypergeometric distribution? #3315

Open austinv11 opened 10 months ago

austinv11 commented 10 months ago

Issue Description

In my work I need to develop a generative model that makes use of the Hypergeometric distribution. I believe torch.multinomial without replacement is equivalent? But it is of course, incompatible with pyro.sample statements.

Suggestions for alternative distributions would also be appreciated.

Thanks for your consideration!

martinjankowiak commented 10 months ago

torch.multinomial provides a sampler. a full-fledged distribution also requires a log_prob. however afaik evaluating the hypergeometric function involves nasty special functions that aren't available in pytorch

possibly relevant links: https://github.com/google-deepmind/torch-cephes https://github.com/pytorch/pytorch/issues/76324 https://github.com/pytorch/pytorch/issues/3877 https://github.com/pytorch/pytorch/issues/36036

austinv11 commented 10 months ago

Ah, that's unfortunate. Thanks for the info! Feel free to close.