Wraps binsegRcpp::binseg() (Hocking): a C++ binary segmentation
that runs in \(O(n \log n)\) for the best case and supports several
loss functions, including ones no other engine here offers (Poisson,
\(\ell_1\)). It is the package's performance path for binary
segmentation on long series, and it returns the whole nested family of
segmentations, so it also feeds cpt_solution_path().
Usage
binsegrcpp_wrapper(
x,
change_in = c("mean", "meanvar"),
distribution = NULL,
max_segments = NULL,
n_segments = NULL,
min_segment_length = NULL
)Arguments
- x
A numeric vector.
- change_in
"mean"(Gaussian, the default) or"meanvar", mapped to the engine'smean_normandmeanvar_normdistributions. binsegRcpp has no variance-only cost, so"var"is not offered here — use"meanvar", orcpt_detect(method = "pelt", change_in = "var")for a variance-only change.- distribution
Loss function, overriding the mapping from
change_in. RunbinsegRcpp::get_distribution_info()for the list ("mean_norm","meanvar_norm","poisson","l1", ...).- max_segments
Largest number of segments searched. Defaults to
min(20, floor(n / 5)).- n_segments
Number of segments to report. When
NULL(the default) it is chosen by BIC over the nested family the engine returns.- min_segment_length
Minimum segment length. Passed through when supplied.
References
Hocking TD (2024). “Finite sample complexity analysis of binary segmentation.” arXiv preprint arXiv:2410.08654. doi:10.48550/arXiv.2410.08654 .
See also
Other changepoint engines:
bcp_wrapper(),
beast_wrapper(),
bfast_wrapper(),
bocpd_wrapper(),
cpm_wrapper(),
cpop_wrapper(),
cpt_wrapper(),
decafs_wrapper(),
ecp_wrapper(),
envcpt_wrapper(),
esac_wrapper(),
fabisearch_wrapper(),
fastcpd_wrapper(),
fcov_wrapper(),
fmean_wrapper(),
fpop_wrapper(),
geomcp_wrapper(),
hdcov_wrapper(),
hdreg_wrapper(),
idetect_wrapper(),
inspect_wrapper(),
kcp_wrapper(),
kwc_wrapper(),
mcp_wrapper(),
mosum_wrapper(),
network_wrapper(),
not_wrapper(),
npmojo_wrapper(),
nsp_wrapper(),
ocd_wrapper(),
pilliat_wrapper(),
segmented_wrapper(),
smuce_wrapper(),
sn_wrapper(),
strucchange_wrapper(),
taylor_wrapper(),
tguh_wrapper(),
trend_wrapper(),
var_wrapper(),
wbs2_wrapper(),
wbs_wrapper(),
wbsts_wrapper()
Examples
set.seed(2026)
binsegrcpp_wrapper(c(rnorm(100), rnorm(100, 3)))
#> ggcpt (changepoint detection result)
#> Method: binsegrcpp
#> Change in: mean
#> Changepoints found: 1
#> CP convention: left
#> Penalty: BIC over nested family = 2
#> Series length: 200
#>
#> Changepoints:
#> # A tibble: 1 × 2
#> cp cp_value
#> <int> <dbl>
#> 1 100 0.369
