-
-
Notifications
You must be signed in to change notification settings - Fork 385
Reduce Boost dependency footprint #3405
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
Open
andrjohns
wants to merge
15
commits into
develop
Choose a base branch
from
boost-repl-stan
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
490411a
Replace boost random with std
andrjohns 51eded8
Remove dead includes
andrjohns 5178da7
Remove boost/algorithm usages
andrjohns ea93d96
Update RNG usage and test expectations
andrjohns a81db20
Replace boost/regex usage
andrjohns d50a260
Replace circular_buffer
andrjohns 7c0ff41
Replace accumulators usage
andrjohns bbff16b
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot 0d91b3c
Update hardcoded expectations
andrjohns 1764ef9
Update tolerance
andrjohns 7192fd7
ring_buffer: guard 0-capacity, use moves, add tests
andrjohns e978161
Optimise/simplify string utils, add tests
andrjohns 1e1c33e
Merge commit 'f7437d911374df788a9f108297bdb493b2ae5bd7' into HEAD
yashikno 32814ac
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot 7d27504
Remove usages in tests
andrjohns File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should use a little variance function like the below that uses welford's algorithm so we can be a bit more precise
https://godbolt.org/z/Porcq1z8W
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.
Interesting! I was looking into the speed/accuracy tradeoff from switching from vectorised Eigen to welford's, and it's showing the Eigen vectorised impl as being more accurate still: https://godbolt.org/z/G33637P6r.
I've also attached the version that did a timing comparison across a larger range as well.
I'm not overly-confident that Claude isn't missing something obvious though, are there any particular edge-cases or examples where you've seen the welford benefits that I can test with? I was always under the impression that the main motivator was for online/streaming cases rather than with a fully-materialised case.
variance_accuracy.cpp
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.
We do have existing welford estimators for variance and covariance in the Math library that I could switch to here and for the covariance below:
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.
Relative to @andrjohns' file variance_accuracy.cpp.
eigen_twopass is generally more accurate, but can fail in extreme cases. John Cook has a post about this. It's not clear how common such cases are.
I've always written the variance calculations for welford_seq as
m2 += -m2 * inv + delta * delta * inv * (1 - inv);and then returnm2 * n / (n - 1);, which proves a bit more accurate than welford_seq, and otherwise follows the pattern of the bullet point above.