Comments (13)
Things that need to happen:
- Create a new, parallel file to the
check_*
file calledis_*
. - Add a new, parallel file to the test file.
- Add tests for the new function.
- Write the new function.
- Change the implementation of the check.
Later down the road, we'll need to reopen stan#1104 and expose all the functions. And add it to the doc.
from math.
Hey, Bob was suggesting I take a crack at this and I have a few questions about what we want to do here. First, my attempt to paraphrase the high level goal: We want to allow Stan users to use a standard set of error checking functions for use typically in their Stan code's functions
block (i.e. User Defined Functions), and we think the functions listed above on this ticket are good candidates for end use. I'm a bit lost as to why we want to create copies of the checks with slightly different names (the check_*
-> is_*
step above)? Also, Bob mentioned that we wanted to do some clean up and vectorization here, and I'm wondering what the clean up especially should look like. @bob-carpenter might be the best person to answer at least parts of this.
from math.
from math.
Just to be clear, are we expecting things like is_positive
to be vectorized, or just the check_positive
version? Given that bool is_positive(...)
couldn't return information about where the error occurred, I think the latter makes more sense but just want to run that by you guys while I'm working on it.
from math.
from math.
https://github.com/stan-dev/math/tree/feature/issue-50-boolean_functions
https://github.com/stan-dev/math/tree/feature/issue-50-error_handling_functions
from math.
@bob-carpenter, I forgot that there's another reason for these error checking functions. I was thinking that we'd have the boolean functions able to take in the different Stan types, including arrays. The check functions would be responsible for passing the right information back to the user. But a user could use these functions.
So... if we have something like:
vector[3] x[4]
from the Stan language, we could do something like is_positive(x)
and it'll give us a sensible result.
The check_positive()
would really try to indicate which element was wrong. Maybe at some point, we can have the generated code pass in the correct variable name (cc @seantalts @VMatthijs), but that's beyond the scope of this issue.
from math.
These check_ functions are still missing corresponding is_ functions:
- stan/math/prim/err/check_vector.hpp
Don't be confused, there's an is_vector; but it's a compile time check implemented with a meta program. Totally different thing. - stan/math/prim/err/check_simplex.hpp
- stan/math/prim/err/check_positive_ordered.hpp
- stan/math/prim/err/check_pos_semidefinite.hpp
- stan/math/prim/err/check_cov_matrix.hpp
- stan/math/prim/err/check_positive_finite.hpp
- stan/math/prim/err/check_nonnegative.hpp
- stan/math/prim/err/check_less.hpp
- stan/math/prim/err/check_greater_or_equal.hpp
- stan/math/prim/err/check_greater.hpp
There is an is_less_or_equal, but is_less, is_greater, and is_greater_or_equal are missing. - stan/math/prim/err/check_bounded.hpp
- stan/math/prim/err/check_multiplicable.hpp
- stan/math/prim/err/check_row_index.hpp
There is an is_column_index, but is_row_index is missing. - stan/math/prim/err/check_vector_index.hpp
- stan/math/prim/err/check_range.hpp
These missing is functions obviously aren't needed in the math library, so the only reason to create them would be to expose them to Stan users. If we don't want to do that this ticket should be closed.
I don't think we need is functions for these. They don't seem like the kind of conditions that Stan users would want to evaluate (?):
- stan/math/prim/err/check_consistent_size.hpp
- stan/math/prim/err/check_consistent_sizes.hpp
- stan/math/prim/err/check_consistent_size_mvt.hpp
- stan/math/prim/err/check_consistent_sizes_mvt.hpp
- stan/math/prim/err/check_2F1_converges.hpp
- stan/math/prim/err/check_3F2_converges.hpp
Nor do we need is functions for these:
- stan/math/prim/err/check_nonempty.hpp
check_nonempty is redundant with check_nonzero_size and is_nonzero_size. - stan/math/prim/err/check_std_vector_index.hpp
check_std_vector_index is redundant with check_vector_index; we do need an is_vector_index though.
from math.
Excellent summary. Yes, we still want to expose both check-X and is-X functions in Stan.
I think we may be missing extensions of some of these to containers, which we also need in the math lib. There are still lots of places in math lib code with checks embedded in loops that should be refactored in order to report the index properly and simplify code.
from math.
Yeah. Stuff like check_symmetric can easily be lifted to work on std::vector<std::vector<Eigen::MatrixXd>> and so forth.
from math.
That would be good for the multivariate distributions and just so that everything works the same way no matter the base type on which the test is being done.
from math.
The bulk of these functions have been finished and tested here: https://github.com/kw-fn/math, unfortunately at the time I was working on this the rest of library was going through a series of changes which caused the PR to bit-rot rather quickly, since I didn't have the capacity to solve the (then rather deep) compiler errors the PR has stalled. It would be great to see if the codes can be safely integrated into the Stan-lang math library.
from math.
(+) I have some free time to push this.
from math.
Related Issues (20)
- Expose variadic arguments for algebra_solver HOT 5
- log1p_exp() for logistic_lcdf() and logistic_lccdf() HOT 2
- Cleanup accumulator? HOT 5
- ODE Methods not `fvar<T>` compatible HOT 4
- Use finite-differences where forward-mode not implementable
- weibull_lcdf might not have been implemented in the best way HOT 2
- Convolution in 1D and 2D using fft
- Add tuple-returning versions of special functions HOT 1
- Errors when right-censoring: bug in normal_lccdf? HOT 6
- Segmentation fault on making use of `ode_rk45` with `integrate_1d` HOT 5
- Tests fail to link: ld: error: undefined symbol: tbb::internal::task_scheduler_observer_v3::observe(bool)
- Add `select()` and `any()` helper functions HOT 1
- Incomplete type compilation error for hessian HOT 3
- Update Cholesky factors
- boost 1.81.0 upgrade HOT 1
- `grad2F1` can terminate too early when only some gradients are requested HOT 4
- [Feature] Add a bracketing rootfinder HOT 6
- Jenkins OpenCL tests failing on jenkins2 but not jenkins1 HOT 3
- Testing: decrease impact of distribution tests on CI hardware HOT 5
- SDE distribution
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from math.