{"id":21424960,"url":"https://github.com/arkhipenko/runninglinreg","last_synced_at":"2026-01-07T15:31:12.722Z","repository":{"id":187971232,"uuid":"501081025","full_name":"arkhipenko/RunningLinreg","owner":"arkhipenko","description":"Implementation of dynamic mean squared error linear regression f(t)","archived":false,"fork":false,"pushed_at":"2022-06-08T11:26:31.000Z","size":5,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-22T21:31:47.320Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arkhipenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-06-08T03:05:41.000Z","updated_at":"2024-11-22T12:28:45.000Z","dependencies_parsed_at":"2023-08-13T03:06:01.460Z","dependency_job_id":null,"html_url":"https://github.com/arkhipenko/RunningLinreg","commit_stats":null,"previous_names":["arkhipenko/runninglinreg"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkhipenko%2FRunningLinreg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkhipenko%2FRunningLinreg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkhipenko%2FRunningLinreg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkhipenko%2FRunningLinreg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arkhipenko","download_url":"https://codeload.github.com/arkhipenko/RunningLinreg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235240393,"owners_count":18958225,"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":[],"created_at":"2024-11-22T21:25:56.690Z","updated_at":"2025-10-04T10:32:01.371Z","avatar_url":"https://github.com/arkhipenko.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Running Linreg\n\n### Implementation of dynamic MSE linear regression f(t)\n##### Version 1.0.0\n\n### Description\n\n`Running Linreg` (or Linear Regression) implements dynamic (and fast) recalculated mean squared error linear regression f(t) based on a pre-defined number of points. \n\nEach time a new point is added to the set, the **slope** and **intercept** values are recalculated based on the added point values **only.**\n\n### Detailed explanation\n\nImagine you are calculating the closest linear representation of a time series array of 200 points. As you continue measuring, new points are added on the right side, and every time a point is added on the right beyond initial 200, another point is dropped on the left. Thus you maintain a Running Array of measurement points, and linear regression characteristics of a line closely approximating the time-series. As only two points are changing at every measurement (the left-most is dropped and the right-most is added), the library does not need to recalculate slope/intercept based on all 200 points, just the effect of those two, hence the speed. \n\n### Usage:\n\nConstruct the `RunningLinreg` object giving it a pointer to a `std::queue` object to hold `point_t` objects and anticipated size of the time-series array\n\n```c++\nRunningLinreg(std::queue\u003cpoint_t\u003e* points, size_t n);\n```\n\nUse this method to add a point to the set:\n\n```c++\naddPoint(point_t point);\n```\n\nThen query recalculated **slope** and **intercept** values using methods:\n\n```c++\ndouble   slope();\ndouble   intercept();\n```\n\nMethods \n\n```c++\ndouble   count();\nint16_t  status();\n```\n\ncould be used to query total number of points already added, and if errors were encountered by the last method call. \n\nThe point definition is:\n\n```c++\ntypedef struct {\n  double  t;\n  double  value;\n} point_t;\n```\n\nand a list of error codes is below:\n\n```c++\n#define LINREG_OK       0\n#define LINREG_ERR      (-1) //  general error\n#define LINREG_NUL      (-2) //  points pointer is NULL\n#define LINREG_DEN      (-3) //  denominator is zero\n```\n\n### Practical applications\n\n- Peak detection\n- PID control \n\n\n\n**Enjoy!**\n\n\n\n###### Changelog:\n\nv1.0.0:\n\n- 2022-06-08 - initial release\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkhipenko%2Frunninglinreg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farkhipenko%2Frunninglinreg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkhipenko%2Frunninglinreg/lists"}