{"id":28789080,"url":"https://github.com/mstorath/cssd","last_synced_at":"2025-10-24T14:08:40.920Z","repository":{"id":178172942,"uuid":"495005582","full_name":"mstorath/CSSD","owner":"mstorath","description":"Smoothing splines for signals with discontinuities","archived":false,"fork":false,"pushed_at":"2025-06-16T15:31:46.000Z","size":476,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-16T16:38:56.068Z","etag":null,"topics":["changepoint-detection","discontinuities","matlab","piecewise-regression","smoothing","splines","step-detection"],"latest_commit_sha":null,"homepage":"","language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mstorath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2022-05-22T08:47:43.000Z","updated_at":"2025-06-16T15:31:51.000Z","dependencies_parsed_at":"2024-01-17T18:34:28.680Z","dependency_job_id":"b6866690-6db7-4ae2-86f2-4aaa76c3e354","html_url":"https://github.com/mstorath/CSSD","commit_stats":null,"previous_names":["mstorath/cssd"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mstorath/CSSD","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstorath%2FCSSD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstorath%2FCSSD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstorath%2FCSSD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstorath%2FCSSD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mstorath","download_url":"https://codeload.github.com/mstorath/CSSD/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstorath%2FCSSD/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260447619,"owners_count":23010540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["changepoint-detection","discontinuities","matlab","piecewise-regression","smoothing","splines","step-detection"],"created_at":"2025-06-17T22:00:32.689Z","updated_at":"2025-10-24T14:08:40.914Z","avatar_url":"https://github.com/mstorath.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSSD - Cubic smoothing splines for discontinuous signals\n\nThis is a reference implementation in Matlab for the algorithms described in the paper\n\n**M. Storath, A. Weinmann, \"Smoothing splines for discontinuous signals\", Journal of Computational and Graphical Statistics, 2023, [[Preprint](\nhttps://doi.org/10.48550/arXiv.2211.12785)]**\n\n## Overview of main functionalities\n1. **cssd.m** computes a cubic smoothing spline with discontinuities (CSSD) for data (x,y). It is a solution of the following model of a smoothing spline $f$ with a-priori unknown discontinuities $J$\n\n  $$\\min_{f, J} p \\sum_{i=1}^N \\left(\\frac{y_i - f(x_i)}{\\delta_i}\\right)^2   +  (1-p) \\int_{[x_1, x_N] \\setminus J}   (f''(t))^2 dt\t + \\gamma |J|.$$\n\n  where\n  *  $y_i = g(x_i) + \\epsilon_i$ are samples of piecewise smooth function $g$ at data sites $x_1, \\ldots, x_N$, and an estimate $\\delta_i$  of the standard deviation of the errors $\\epsilon_i$\n  * the minimum is taken over all possible sets of discontinuities between two data sites $J \\subset [x_1, x_N]\\setminus \\{x_1, \\ldots, x_N\\}$\n   and all functions $f$ that are twice continuously differentiable away from the discontinuities.\n  * The model parameter $p \\in (0, 1)$ controls the relative weight of the smoothness term (second term) and the data fidelity term.\n  * The last term is a penalty for the number of discontinuities $|J|$ weighted by a parameter $\\gamma \u003e 0.$ \n\n2. **cssd_cv.m** automatically determines values for the model parameters $p$ and $\\gamma$ based on K-fold cross validation.\n\n## Quickstart\n1. Execute \"install_cssd.m\" which adds the folder and all subfolders to the Matlab path.\n2. Execute any m-file from the demos folder\n\n## Examples\n\n### Synthetic data\n\u003cfigure\u003e\n  \u003cimg src=\"images/Ex_Synthetic.png\" alt=\"Synthetic signal\" width=\"600\"/\u003e\n  \u003cfigcaption\u003eA synthetic signal is sampled at $N = 100$ random data sites $x_i$ \n\tand corrupted by zero mean Gaussian noise with standard deviation \n$0.1.$\n\tThe results of the discussed model are shown for $p=0.999$ and different parameters of $\\gamma,$ where $\\gamma=\\infty$  corresponds to classical smoothing splines.\n\tThe thick lines \nrepresent the results of the shown sample realization.\t The shaded areas depict the $2.5 \\%$ to $97.5 \\%$  (pointwise) quantiles of $1000$ realizations. The histograms under the plots show the frequency of the detected discontinuity locations over all realizations.\n\u003c/figcaption\u003e\n\u003c/figure\u003e\n\n### Stock data\n\u003cfigure\u003e\n  \u003cimg src=\"images/Ex_Stock_CV.png\" alt=\"Stock\" width=\"600\"/\u003e\n  \u003cfigcaption\u003eThe dots represent the logarithm of the closing prices of the Meta stock from May 18, 2012, \n\tto May 19, 2022. The curve represents the CSSD with parameters determined by K-fold CV ($p = 0.4702$,  $\\gamma = 0.0069$). The dashed vertical lines indicate the discontinuities of the CSSD, and the ticks correspond to the date before the discontinuity.\n\u003c/figcaption\u003e\n\u003c/figure\u003e\n\n### Geyser data\n\u003cfigure\u003e\n  \u003cimg src=\"images/Ex_Geyser_CV.png\" alt=\"Geyser\" width=\"600\"/\u003e\n  \u003cfigcaption\u003eFitting a CSSD to the Old Faithful data (circles):\n\tIf the parameter is selected based on K-fold CV\n\twe obtain a result without discontinuities which coincides with a classical smoothing spline (solid curve).\n\tKeeping the selected $p$-parameter and lowering the $\\gamma$ parameter sufficiently gives a two-phase regression curve (dashed curves) with a breakpoint near $x = 3$ (dashed vertical line), and the two curve segments are nearly linear. \n\tBoth of the above parameter sets yield better CV-scores  than a linear model (dotted line).\n\u003c/figcaption\u003e\n\u003c/figure\u003e\n\n## Reference\n\nM. Storath, A. Weinmann, \"Smoothing splines for discontinuous signals\", Journal of Computational and Graphical Statistics, 2023\n\n## See also \n\n- [Higher order Mumford-Shah models (discrete splines with discontinuities)](https://github.com/lu-kie/HOMS_SignalProcessing)\n- [Degrees of freedom penalized regression](https://github.com/SV-97/pcw-regrs)\n- [Pottslab](https://github.com/mstorath/Pottslab)\n- [L1TV regularization](https://github.com/mstorath/L1TV)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstorath%2Fcssd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmstorath%2Fcssd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstorath%2Fcssd/lists"}