{"id":32199986,"url":"https://github.com/doccstat/fastcpd","last_synced_at":"2026-03-12T22:31:17.929Z","repository":{"id":161967060,"uuid":"538772555","full_name":"doccstat/fastcpd","owner":"doccstat","description":"Fast Change Point Detection in R","archived":false,"fork":false,"pushed_at":"2025-08-16T18:05:03.000Z","size":105861,"stargazers_count":24,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-12T16:40:10.319Z","etag":null,"topics":["change-point-detection","cpp","custom-function","gradient-descent","lasso","linear-regression","logistic-regression","offline","pelt","penalized-regression","poisson-regression","pypi-package","python","python3","quasi-newton","r","r-package","statistics","time-series","warm-start"],"latest_commit_sha":null,"homepage":"https://fastcpd.xingchi.li/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doccstat.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-09-20T02:08:33.000Z","updated_at":"2026-01-01T09:24:30.000Z","dependencies_parsed_at":"2024-03-10T23:27:38.447Z","dependency_job_id":"44e3931f-7191-400f-b534-f65294a8ffec","html_url":"https://github.com/doccstat/fastcpd","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/doccstat/fastcpd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doccstat%2Ffastcpd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doccstat%2Ffastcpd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doccstat%2Ffastcpd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doccstat%2Ffastcpd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doccstat","download_url":"https://codeload.github.com/doccstat/fastcpd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doccstat%2Ffastcpd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30446445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T21:31:01.033Z","status":"ssl_error","status_checked_at":"2026-03-12T21:30:43.161Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["change-point-detection","cpp","custom-function","gradient-descent","lasso","linear-regression","logistic-regression","offline","pelt","penalized-regression","poisson-regression","pypi-package","python","python3","quasi-newton","r","r-package","statistics","time-series","warm-start"],"created_at":"2025-10-22T03:34:38.439Z","updated_at":"2026-03-12T22:31:17.921Z","avatar_url":"https://github.com/doccstat.png","language":"C++","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\"\n)\noptions(cli.hyperlink = FALSE, eval = TRUE)\n```\n\n# Fast Change Point Detection \u003ca href=\"https://fastcpd.xingchi.li\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" /\u003e\u003c/a\u003e\n\n[![Codecov test coverage](https://codecov.io/gh/doccstat/fastcpd/branch/main/graph/badge.svg)](https://app.codecov.io/gh/doccstat/fastcpd?branch=main)\n[![CodeFactor](https://www.codefactor.io/repository/github/doccstat/fastcpd/badge)](https://www.codefactor.io/repository/github/doccstat/fastcpd)\n[![CRAN status](https://www.r-pkg.org/badges/version-last-release/fastcpd)](https://cran.r-project.org/package=fastcpd)\n[![doi](https://img.shields.io/badge/doi-10.48550/arXiv.2404.05933-green.svg)](https://doi.org/10.48550/arXiv.2404.05933)\n[![R-CMD-check.yaml](https://github.com/doccstat/fastcpd/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/doccstat/fastcpd/actions)\n[![r-universe](https://doccstat.r-universe.dev/badges/fastcpd)](https://doccstat.r-universe.dev)\n[![Python version](https://img.shields.io/pypi/pyversions/fastcpd)](https://pypi.org/project/fastcpd/)\n[![Python package](https://img.shields.io/pypi/v/fastcpd)](https://pypi.org/project/fastcpd/)\n\n## Overview\n\nThe fastcpd (**fast** **c**hange **p**oint **d**etection) is a fast\nimplmentation of change point detection methods in R/Python.\n\n### Documentation\n\n* R documentation: [fastcpd.xingchi.li](https://fastcpd.xingchi.li)\n* Python documentation: [fastcpd.xingchi.li/python](https://fastcpd.xingchi.li/python)\n\n## Installation\n\n### R\n\n```{r eval = FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"doccstat/fastcpd\")\n# or install from CRAN\ninstall.packages(\"fastcpd\")\n```\n\n### Python WIP\n\n``` shell\n# python -m ensurepip --upgrade\npip install .\n# or install from PyPI\npip install fastcpd\n```\n\n## Usage\n\n### R\n\n```{r ar3}\nset.seed(1)\nn \u003c- 1000\nx \u003c- rep(0, n + 3)\nfor (i in 1:600) {\n  x[i + 3] \u003c- 0.6 * x[i + 2] - 0.2 * x[i + 1] + 0.1 * x[i] + rnorm(1, 0, 3)\n}\nfor (i in 601:1000) {\n  x[i + 3] \u003c- 0.3 * x[i + 2] + 0.4 * x[i + 1] + 0.2 * x[i] + rnorm(1, 0, 3)\n}\nresult \u003c- fastcpd::fastcpd.ar(x[3 + seq_len(n)], 3, r.progress = FALSE)\nsummary(result)\nplot(result)\n```\n\n### Python WIP\n\n``` python\nimport fastcpd.segmentation\nfrom numpy import concatenate\nfrom numpy.random import normal, multivariate_normal\ncovariance_mat = [[100, 0, 0], [0, 100, 0], [0, 0, 100]]\ndata = concatenate((multivariate_normal([0, 0, 0], covariance_mat, 300),\n                    multivariate_normal([50, 50, 50], covariance_mat, 400),\n                    multivariate_normal([2, 2, 2], covariance_mat, 300)))\nfastcpd.segmentation.mean(data)\n\nimport fastcpd.variance_estimation\nfastcpd.variance_estimation.mean(data)\n```\n\n### Comparison\n\n```{r time-comparison-small}\nlibrary(microbenchmark)\nset.seed(1)\nn \u003c- 5 * 10^6\nmean_data \u003c- c(rnorm(n / 2, 0, 1), rnorm(n / 2, 50, 1))\nggplot2::autoplot(microbenchmark(\n  wbs = wbs::wbs(mean_data),\n  not = not::not(mean_data, contrast = \"pcwsConstMean\"),\n  changepoint = changepoint::cpt.mean(mean_data, method = \"PELT\"),\n  jointseg = jointseg::jointSeg(mean_data, K = 12),\n  fpop = fpop::Fpop(mean_data, 2 * log(n)),\n  mosum = mosum::mosum(c(mean_data), G = 40),\n  fastcpd = fastcpd::fastcpd.mean(mean_data, r.progress = FALSE, cp_only = TRUE, variance_estimation = 1)\n))\n```\n\n```{r time-comparison-large}\nlibrary(microbenchmark)\nset.seed(1)\nn \u003c- 10^8\nmean_data \u003c- c(rnorm(n / 2, 0, 1), rnorm(n / 2, 50, 1))\nsystem.time(fastcpd::fastcpd.mean(mean_data, r.progress = FALSE, cp_only = TRUE, variance_estimation = 1))\nsystem.time(mosum::mosum(c(mean_data), G = 40))\nsystem.time(fpop::Fpop(mean_data, 2 * log(n)))\nsystem.time(changepoint::cpt.mean(mean_data, method = \"PELT\"))\nggplot2::autoplot(microbenchmark(\n  changepoint = changepoint::cpt.mean(mean_data, method = \"PELT\"),\n  fpop = fpop::Fpop(mean_data, 2 * log(n)),\n  mosum = mosum::mosum(c(mean_data), G = 40),\n  fastcpd = fastcpd::fastcpd.mean(mean_data, r.progress = FALSE, cp_only = TRUE, variance_estimation = 1),\n  times = 10\n))\n```\n\nSome packages are not included in the `microbenchmark` comparison due to either\nmemory constraints or long running time.\n\n```r\n# Device: Mac mini (M1, 2020)\n# Memory: 8 GB\nsystem.time(CptNonPar::np.mojo(mean_data, G = floor(length(mean_data) / 6)))\n#\u003e Error: vector memory limit of 16.0 Gb reached, see mem.maxVSize()\n#\u003e Timing stopped at: 0.061 0.026 0.092\nsystem.time(ecp::e.divisive(matrix(mean_data)))\n#\u003e Error: vector memory limit of 16.0 Gb reached, see mem.maxVSize()\n#\u003e Timing stopped at: 0.076 0.044 0.241\nsystem.time(strucchange::breakpoints(y ~ 1, data = data.frame(y = mean_data)))\n#\u003e Timing stopped at: 265.1 145.8 832.5\nsystem.time(breakfast::breakfast(mean_data))\n#\u003e Timing stopped at: 45.9 89.21 562.3\n```\n\n## Cheatsheet\n\n[![fastcpd cheatsheet](man/figures/cheatsheets.png)](https://github.com/doccstat/fastcpd/blob/main/man/figures/cheatsheets.pdf)\n\n### References\n\n* [fastcpd: Fast Change Point Detection in R](https://doi.org/10.48550/arXiv.2404.05933)\n* [Sequential Gradient Descent and Quasi-Newton's Method for Change-Point Analysis](https://proceedings.mlr.press/v206/zhang23b.html)\n\n## FAQ\n\n\u003cdetails close\u003e\n\n\u003csummary\u003eShould I install suggested packages?\u003c/summary\u003e\n\nThe suggested packages are not required for the main functionality of the\npackage. They are only required for the vignettes. If you want to\nlearn more about the package comparison and other vignettes, you could either\ncheck out vignettes on [CRAN](https://CRAN.R-project.org/package=fastcpd) or\n[pkgdown generated documentation](https://fastcpd.xingchi.li/articles/).\n\n\u003c/details\u003e\n\n\u003cdetails close\u003e\n\n\u003csummary\u003eI countered problems related to gfortran on Mac OSX or Linux!\u003c/summary\u003e\n\nThe package should be able to install on Mac and any Linux distribution without any problems if all the\ndependencies are installed. However, if you encountered problems related to\ngfortran, it might be because `RcppArmadillo` is not installed previously.\nTry [Mac OSX stackoverflow solution](https://stackoverflow.com/a/72997915) or\n[Linux stackover solution](https://stackoverflow.com/a/15540919) if you have\ntrouble installing `RcppArmadillo`.\n\n\u003c/details\u003e\n\n\u003cdetails close\u003e\n\n\u003csummary\u003eWe welcome contributions from everyone.\nPlease follow the instructions below to make contributions.\u003c/summary\u003e\n\n1.  Fork the repo.\n2.  Create a new branch from `main` branch.\n3.  Make changes and commit them.\n\n    1. Please follow the\n       [Google's R style guide](https://google.github.io/styleguide/Rguide.html)\n       for naming variables and functions.\n    2. If you are adding a new family of models with new cost functions with\n       corresponding gradient and Hessian, please add them to\n       `src/fastcpd_class_cost.cc` with proper example and tests in\n       `vignettes/gallery.Rmd` and\n       `tests/testthat/test-gallery.R`.\n    3. Add the family name to `src/fastcpd_constants.h`.\n    4. [Recommended] Add a new wrapper function in `R/fastcpd_wrappers.R` for\n       the new family of models and move the examples to the new wrapper\n       function as roxygen examples.\n    5. Add the new wrapper function to\n       the corresponding section in `_pkgdown.yml`.\n4.  Push the changes to your fork.\n5.  Create a pull request.\n6.  Make sure the pull request does not create new warnings or errors in\n    `devtools::check()`.\n\n\u003c/details\u003e\n\n\u003cdetails close\u003e\n\n\u003csummary\u003eTrouble installing Python package.\u003c/summary\u003e\n\nPython headers are required to install the Python package. If you are\nusing Ubuntu, you can install the headers with:\n\n``` shell\nsudo apt install python3-dev\n```\n\n\u003c/details\u003e\n\n\u003cdetails close\u003e\n\n\u003csummary\u003eEncountered a bug or unintended behavior?\u003c/summary\u003e\n\n1.  File a ticket at\n    [GitHub Issues](https://github.com/doccstat/fastcpd/issues).\n2.  Contact the authors specified in\n    [DESCRIPTION](https://github.com/doccstat/fastcpd/blob/main/DESCRIPTION#L5-L10).\n\n\u003c/details\u003e\n\n## Stargazers over time\n[![Stargazers over time](https://starchart.cc/doccstat/fastcpd.svg)](https://starchart.cc/doccstat/fastcpd)\n\n## Acknowledgements\n\nSpecial thanks to [clODE](https://github.com/patrickfletcher/clODE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoccstat%2Ffastcpd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoccstat%2Ffastcpd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoccstat%2Ffastcpd/lists"}