math icon indicating copy to clipboard operation
math copied to clipboard

Missing signature support for poisson_binomial

Open rok-cesnovar opened this issue 4 years ago • 8 comments

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):

  • poisson_binomial_rng(int) and poisson_binomial_rng(real) fail to compile to C++ (I think the C++ was not written with these in mind but we typically support rngs for scalars as well)
  • poisson_binomial_rng(vector) and poisson_binomial_rng(row_vector) fail with expressions tests (I think the input is evaluated multiple times)
  • poisson_binomial_lpmf(int, int), poisson_binomial_lpmf(int, real), poisson_binomial_lpmf(array[] int, int), poisson_binomial_lpmf(array[] int, int) and the same for _cdf, _lcdf, _lccdf fail to compile to C++ (I think the C++ was not written with these in mind)
  • the _lpmf/_cdf/_lcdf/_lccdf do not compile for array[] real as the second argument.

rok-cesnovar avatar May 19 '21 07:05 rok-cesnovar

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

dirmeier avatar May 19 '21 07:05 dirmeier

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

rok-cesnovar avatar May 19 '21 08:05 rok-cesnovar

And dont apologize, its all good!

rok-cesnovar avatar May 19 '21 08:05 rok-cesnovar

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

dirmeier avatar Jun 25 '21 22:06 dirmeier

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" ...

t4c1 avatar Jun 28 '21 07:06 t4c1

Cool, thanks @t4c1

dirmeier avatar Jun 28 '21 07:06 dirmeier

@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

rok-cesnovar avatar Jun 28 '21 07:06 rok-cesnovar

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

t-silvers avatar Mar 01 '22 05:03 t-silvers