-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
correctness fixes in neg_binomial_* functions #1663
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks great. This is a lot of work!
I didn't see any new tests. When there are bugs, there should be new tests that fail in the current setup but succeed after the fix.
…gs/RELEASE_500/final)
I've added a bunch of tests (one revealed that one of my patches was incomplete). Ideally this sort of things would be tested with a specific framework or inside the distribution tests, but that would be quite a large undertaking. These test revealed that for inputs of different lengths:
The issues reported in #1531, albeit very confusing, were actually benign, as the variables that appeared to be reassigned in the for loop, were actually local variables within the loop, so they had no negative impact on the rest of the function. Those got cleaned up anyway by earlier patches. |
I'm getting a failure in the
The only change I had in that file was replacing a 1.0 with a 1. Locally, switching it back makes the test pass. I don't understand why this would be a problem, but I'm reverting that optional change and hope tests will pass. |
As long as that's not an argument, you should be OK. If it succeeds with 1.0 as an argument to the lcdf but not 1, that's a bug.
… On Feb 4, 2020, at 11:33 AM, Marco Colombo ***@***.***> wrote:
I'm getting a failure in the neg_binomial_2_lcdf distribution tests:
unknown file: Failure
C++ exception with description "beta_lcdf: Second shape parameter[1] is -2.14748e+09, but must be > 0!" thrown in the test body.
[ FAILED ] AgradCdfLogNegBinomial2_ffv_80/AgradCdfLogTestFixture/0.UpperBound, where TypeParam = boost::mpl::vector<AgradCdfLogNegBinomial2, boost::mpl::vector<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<stan::math::fvar<stan::math::fvar<stan::math::var> >, -1, 1, 0, -1, 1>, Eigen::Matrix<stan::math::fvar<stan::math::fvar<stan::math::var> >, -1, 1, 0, -1, 1>, empty, empty, empty, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> (0 ms)
The only change I had in that file was replacing a 1.0 with a 1. Locally, switching it back makes the test pass. I don't understand why this would be a problem, but I'm reverting that optional change and hope tests will pass.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
It was in an assigmnent to a VectorBuilder, see the last commit. |
Summary
The various
neg_binomial
andneg_binomial_2
functions suffer from several cases in which the loops that construct VectorBuilders are executed the wrong number of times (see examples pointed out in #1662 and #1531). Besides that, these functions can be cleaned up a bit so that intermediate computations are stored in VectorBuilders if they are reused later on, as well as usinginv
andsquare
, and a few other touches here and there.If it helps, I've split the correctness fixes and the rest of cleanup in two different commits. Fixes #1662, fixes #1531, fixes #595.
Tests
Existing tests should continue to pass. I'm not sure that the current distribution test framework allows to test inputs of different sizes.
Side Effects
None.
Checklist
Math issue wrong gradient computations in neg_binomial_*cdf functions #1662
Copyright holder: Marco Colombo
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested