https://github.com/gipert/bayesian-blocks
Julia and C++ Implementations of the bayesian blocks algorithm https://arxiv.org/abs/1207.5578
https://github.com/gipert/bayesian-blocks
bayesian-statistics binning cpp julia
Last synced: about 2 months ago
JSON representation
Julia and C++ Implementations of the bayesian blocks algorithm https://arxiv.org/abs/1207.5578
- Host: GitHub
- URL: https://github.com/gipert/bayesian-blocks
- Owner: gipert
- License: mit
- Created: 2019-01-20T22:02:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-20T15:42:08.000Z (over 2 years ago)
- Last Synced: 2023-08-20T16:58:04.573Z (over 2 years ago)
- Topics: bayesian-statistics, binning, cpp, julia
- Language: C++
- Size: 2.47 MB
- Stars: 1
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bayesian Blocks
Header-only C++ implementation of the Bayesian Blocks argorithm. Plug and play!
```cpp
#include "baeysian_blocks.hpp"
#include "baeysian_blocks_root.hpp" // if you want to rebin ROOT CERN histograms
int main() {
// "data" is a a std::vector containing the observed values
// [optional] "weights" can be used to specify the weight (how many times an observation occurs)
auto change_points = BayesianBlocks::blocks(data, /* optional */ weights);
// "change_points" is a std::vector
// "hist" is a ROOT TH1*
auto h_rebin = dynamic_cast(BayesianBlocks::rebin(hist));
// "h_rebin" is the rebinned histogram
return 0;
}
```
Check out the `BayesianBlocks::blocks` and `BayesianBlocks::rebin` signatures for a more advanced usage. Have a look at [`test/run_test.cc`](https://github.com/gipert/bayesian-blocks/blob/master/test/run_test.cc) too.
Bayesian blocks algorithm reference: *Scargle, J et al. (2012) [https://doi.org/10.1088/0004-637X/764/2/167]*
## The `bblocks` utility
The `bblocks` program rebins all the 1-dim histograms contained in a ROOT file.
Install:
```console
$ cd cpp
$ PREFIX= make install
```
Run:
```console
$ bblocks --help
USAGE: bblocks [-v|--verbose] [-h|--help] [--p0 (default 0.01)] file1 file2 ...
```
### Related
Julia language enthusiast? Checl out my Julia package: https://github.com/gipert/BayesianBlocks.jl