-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
generalized uniform #2133
generalized uniform #2133
Conversation
Hmm, this is only failing due to tight tolerances (in test_repeat_as_vector second order gradients differ by 2.2e-14). @bbbales2 Is it possible to increase tolerances just for one function? |
Yeah this seems a bit weird. I want some time to look at it. The error went away when I changed the first lcdf test case to:
from:
It seems weird that that would have made so much of a difference for such simple functions. Anyway I will get to this after the release is sorted out. |
@bbbales2 Do you have time to look into this now? |
@t4c1 yeah. I guess with release out no excuse to procrastinate |
Alright I am confused. I was trying to simplify the computations a bit in the hopes that this went away and I am stuck. The test I'm running is:
If I replace:
with:
Things work. If I replace it with:
The test fails. I have tried evaluating this expression to a temporary. Anyway I'm not sure what is going on. I will come back to this tomorrow with a fresh head and try again. |
Alright got it, but Github didn't let me push to your branch. This code passes for me: const auto& b_minus_a
= to_ref_if<!is_constant_all<T_low, T_high>::value>(beta_val
- alpha_val);
const auto& y_minus_alpha
= to_ref_if<!is_constant_all<T_y, T_low>::value>(y_val - alpha_val);
const auto& cdf_log_n = y_minus_alpha / b_minus_a;
T_partials_return cdf_log = sum(log(cdf_log_n));
if (!is_constant_all<T_y>::value) {
if(!is_vector<T_y>::value &&
is_vector<T_high>::value &&
!is_vector<T_low>::value) {
ops_partials.edge1_.partials_ = size(beta) * inv(y_minus_alpha);
} else {
ops_partials.edge1_.partials_ = inv(y_minus_alpha);
}
}
if (!is_constant_all<T_low>::value) {
ops_partials.edge2_.partials_
= (y_val - beta_val) / (b_minus_a * y_minus_alpha);
}
if (!is_constant_all<T_high>::value) {
if (is_vector<T_y>::value && !is_vector<T_low>::value
&& !is_vector<T_high>::value) {
ops_partials.edge3_.partials_
= inv(-b_minus_a) * size(y);
} else {
ops_partials.edge3_.partials_ = inv(-b_minus_a);
}
} It replaces |
# Conflicts: # test/expressions/stan_math_sigs_exceptions.expected
…4.1 (tags/RELEASE_600/final)
…into generalize_uniform
# Conflicts: # test/expressions/generateExpressionTests.py # test/expressions/stan_math_sigs_exceptions.expected
# Conflicts: # test/expressions/stan_math_sigs_exceptions.expected
# Conflicts: # test/expressions/generateExpressionTests.py # test/expressions/stan_math_sigs_exceptions.expected
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
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.
Good!
Summary
Generalizes uniform distribution related functions to accept Eigen expressions.
Tests
Tested using expression testing framework.
Side Effects
None.
Release notes
Generalized uniform distribution related functions to accept Eigen expressions.
Checklist
Math issue Generalize matrix function signatures #1470
Copyright holder: Tadej Ciglarič
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