-
-
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
test internal math functions F32, gradF32, grad2F1, gradRegIncBeta for infinite loops #27
Comments
What tests do these function need? If anyone knows, please edit the issue to add a list of tests. |
I started working on The first problem I run into is
This is in the unit test on the branch: If there's something wrong with the input, we really need to doc the function. |
Bump. I've gotten a first test up and it doesn't look good. Check out branch Run:
|
I started working on this branch. |
Maybe I just haven't read the functions correctly but I was trying to find consequences to this issue in the user-facing functions and it turns out this test (that I just wrote) fails with a
With this output:
|
Turns out F32 also needs to terminate when the denominator for the rising factorial bits goes to 0. Once I push it will match mathematica results and have tests for that condition. Also, sign needs to be applied after exp, also fixing that. I'm not sure it was ever right except for a limited number of arguments (?) |
Sounds good. I don't even know what this function is or where it's used, but might as well fix it if it's getting called from elsewhere. If it's not getting called anywhere, we can get rid of it unless it's there pending being exposed to the Stan language.
|
It gets called by the beta-binomial CDF and it's related to some functions that make my delay-time models hang so I'm just going to plow through all these if I can. I am setting up some tests against results from Mathematica so if you have any suggestions about how to do that better I appreciate suggestions. It's one of the less common instances of the generalized hypergeometric function |
I think this just became a meta-issue after I dug through these and figured out what they needed. I'll open and fix smaller ones as I go. Currently, check as fixed some issues in these functions produce wrong results or infinite loops.
Design across these functions:
Some issues are maintenance-related
Some issues are cosmetic but it makes it hard to figure out errors and write tests:
|
I have a problem with grad_reg_inc_beta function. |
For example, in the grad_reg_inc_beta_test.cpp
If I change alpha = 2.5, beta = 0.5. I would expect the same g1 = 0. |
Thanks for pointing out the additional test case, I've been working on
these but I don't think I've touched this one in any meaningful way yet. I
will look at this test case but not before finishing the other issue
related to these. If you're trying to use this function the best way to
get help now is to ask on the users mailing list (yes, even for C++ math
lib questions).
…On Tue, Mar 28, 2017 at 5:42 AM hoanguc3m ***@***.***> wrote:
For example, in the grad_reg_inc_beta_test.cpp
`#include <stan/math/prim/scal.hpp>
#include <gtest/gtest.h>
TEST(grad_reg_inc_beta, 1) {
double alpha = 1.0;
double beta = 1.0;
double y = 1.0;
double digamma_alpha = stan::math::digamma(alpha);
double digamma_beta = stan::math::digamma(beta);
double digamma_sum = stan::math::digamma(alpha + beta);
double betafunc = std::exp(stan::math::lbeta(alpha, beta));
double g1 = 0;
double g2 = 0;
stan::math::grad_reg_inc_beta(g1, g2, alpha, beta, y,
digamma_alpha, digamma_beta, digamma_sum,
betafunc);
EXPECT_FLOAT_EQ(0, g1);
EXPECT_FLOAT_EQ(-std::numeric_limits::infinity(), g2);
}
`
If I change alpha = 2.5, beta = 0.5. I would expect the same g1 = 0.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#27 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAfA6aiPHe30jNEMT_XR4OIrYwFT8_Ozks5rqNYGgaJpZM4FTDej>
.
|
Basically all the boxes in this issue are checked, including for grad_reg_inc_beta that relies on a hypergeometric function deep down on the inside (like most of us). |
From @syclik on November 22, 2013 16:21
Issue #333 shows the
gradregIncGamma
function getting into an infinite loop. The additional functions need to be tested:F32
gradF32
grad2F1
gradRegIncBeta
Copied from original issue: stan-dev/stan#410
The text was updated successfully, but these errors were encountered: