stan-dev / math

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
738 stars 186 forks source link

Missing signature support for poisson_binomial #2490

Open rok-cesnovar opened 3 years ago

rok-cesnovar commented 3 years ago

Cleaning up last few things before the release I tried to add poission_binomial to the language but C++ issue arose and should be cleaned up so we can finally expose it (no rush though):

dirmeier commented 3 years ago

Hey Rok, my bad, I thought this was fixed in https://github.com/stan-dev/math/pull/2318. I'll look into it. Cheers, Simon

rok-cesnovar commented 3 years ago

Yeah me too. We missed this when reviewing. Sorry about that. Thanks!

rok-cesnovar commented 3 years ago

And dont apologize, its all good!

dirmeier commented 3 years ago

Hey @rok-cesnovar , is there a way to autogenerate all expression tests that have to pass for a function? Thanks, Simon

t4c1 commented 3 years ago

If the function is already exposed in stan language, the testing framework can get the list of signatures from the compiler. In that case you can run runTests.py ./test/expressions --only-functions poisson_binomial_rng. This one, however, is new, so you need to list all the signatures yourself like runTests.py ./test/expressions --only-functions "poisson_binomial_rng(int) => double" "poisson_binomial_lpmf(array[] int, int) => array[] double" ...

dirmeier commented 3 years ago

Cool, thanks @t4c1

rok-cesnovar commented 3 years ago

@t4c1 is correct, only replace "double" with "real" (too much c++ in Tadej's blood :) ).

These are the full tests that should run successfully (some of them already do):

./runTests.py ./test/expressions --only-functions "poisson_binomial_cdf(int, real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_cdf(int, vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_cdf(int, row_vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_cdf(int, array[] real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_cdf(array[] int, real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_cdf(array[] int, vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_cdf(array[] int, row_vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_cdf(array[] int, array[] real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lcdf(int, real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lcdf(int, vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lcdf(int, row_vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lcdf(int, array[] real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lcdf(array[] int, real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lcdf(array[] int, vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lcdf(array[] int, row_vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lcdf(array[] int, array[] real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lccdf(int, real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lccdf(int, vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lccdf(int, row_vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lccdf(int, array[] real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lccdf(array[] int, real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lccdf(array[] int, vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lccdf(array[] int, row_vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lccdf(array[] int, array[] real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lpmf(int, real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lpmf(int, vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lpmf(int, row_vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lpmf(int, array[] real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lpmf(array[] int, real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lpmf(array[] int, vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lpmf(array[] int, row_vector) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_lpmf(array[] int, array[] real) => real"
./runTests.py ./test/expressions --only-functions "poisson_binomial_rng(int) => int"
./runTests.py ./test/expressions --only-functions "poisson_binomial_rng(real) => int"
./runTests.py ./test/expressions --only-functions "poisson_binomial_rng(vector) => array[] int"
./runTests.py ./test/expressions --only-functions "poisson_binomial_rng(row_vector) => array[] int"
./runTests.py ./test/expressions --only-functions "poisson_binomial_rng(array[] int) => array[] int"
./runTests.py ./test/expressions --only-functions "poisson_binomial_rng(array[] real) => array[] int"

EDIT: fixed names from bernoulii to poisson_binomial

t-silvers commented 2 years ago

Have these functions made it into a release yet? Not seeing it on my end, but apologies if I've missed it. I see here plans for including poisson_binomial_* in v2.27