{"id":18645055,"url":"https://github.com/borchehq/incstats","last_synced_at":"2025-06-29T01:37:23.734Z","repository":{"id":251717551,"uuid":"323726303","full_name":"borchehq/incstats","owner":"borchehq","description":"librstats is a C library for efficient online computation of statistics, such as for mean, variance, skewness and kurtosis.","archived":false,"fork":false,"pushed_at":"2024-09-05T02:40:45.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-17T18:07:59.146Z","etag":null,"topics":["c","central-moments","rolling-average","rolling-statistics","running-statistics","statistics"],"latest_commit_sha":null,"homepage":"","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/borchehq.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-22T20:27:45.000Z","updated_at":"2024-09-05T02:55:25.000Z","dependencies_parsed_at":"2024-11-07T06:14:26.808Z","dependency_job_id":"17066fc4-ea8f-4db1-8bae-afff04addd22","html_url":"https://github.com/borchehq/incstats","commit_stats":null,"previous_names":["borchehq/rstats","borchehq/incstats"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/borchehq/incstats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borchehq%2Fincstats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borchehq%2Fincstats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borchehq%2Fincstats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borchehq%2Fincstats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borchehq","download_url":"https://codeload.github.com/borchehq/incstats/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borchehq%2Fincstats/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262520488,"owners_count":23323723,"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":["c","central-moments","rolling-average","rolling-statistics","running-statistics","statistics"],"created_at":"2024-11-07T06:14:26.428Z","updated_at":"2025-06-29T01:37:23.711Z","avatar_url":"https://github.com/borchehq.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libincstats\n\n**incstats** is a C library for efficiently computing running statistics, such as mean, variance, skewness, kurtosis, central moments, and finding the maximum and minimum values in a dataset. The library is designed to handle weighted data points, making it suitable for a wide range of applications.\n\n## Status\n[![CI](https://github.com/borchehq/incstats/actions/workflows/ci.yml/badge.svg)](https://github.com/borchehq/incstats/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/borchehq/incstats/graph/badge.svg?token=H24FODSV01)](https://codecov.io/gh/borchehq/incstats)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/427138751ae64c2cafe2036c844e0642)](https://app.codacy.com/gh/borchehq/incstats/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade)\n## Features\n\n- Compute running mean, variance, skewness, and kurtosis.\n- Calculate central moments up to a specified order.\n- Calculate standardized central moments up to a specified order.\n- Track maximum and minimum values.\n- Designed for efficiency and simplicity.\n- Handles weighted data points.\n\n## Installation\n\nTo build and install the library, you will need [CMake](https://cmake.org/) version 3.0 or higher. Follow the steps below:\n\n1. Clone the repository:\n```bash\n   git clone https://github.com/borchehq/incstats.git\n   cd incstats\n```\n\n2. Create a build directory and navigate into it:\n```bash\n    mkdir build\n    cd build\n```\n\n3. Configure the project using CMake:\n```bash\n    cmake ..\n```\n\n4. Build the project:\n```bash\n    make\n```\n\n5. Run the tests (optional):\n```bash\n    make test\n```\n\n6. Install the library:\n```bash\n    sudo make install\n```\n\n## Usage\n\nInclude the incstats header files in your project to use the library functions. \nHere is a brief overview of the available functions:\n\nRunning Mean\n```C\ninline void incstats_mean(double x, double w, double *buffer);\ninline void incstats_mean_finalize(double *mean, double *buffer);\n```\n\nRunning Variance\n```C\ninline void incstats_variance(double x, double w, double *buffer);\ninline void incstats_variance_finalize(double *results, double *buffer);\n```\n\nRunning Skewness\n```C\ninline void incstats_skewness(double x, double w, double *buffer);\ninline void incstats_skewness_finalize(double *results, double *buffer);\n```\n\nRunning Kurtosis\n```C\ninline void incstats_kurtosis(double x, double w, double *buffer);\ninline void incstats_kurtosis_finalize(double *results, double *buffer);\n```\n\nCentral Moments\n```C\ninline void incstats_central_moment(double x, double w, double *buffer, uint64_t p);\ninline void incstats_central_moment_finalize(double *results, double *buffer, uint64_t p, bool standardize);\n```\n\nMaximum and Minimum\n```C\ninline void incstats_max(double x, double *max);\ninline void incstats_min(double x, double *min);\n```\n\n\n**Important Note**\nAll functions for higher moments (e.g., kurtosis) will also compute all lower moments \n(e.g., skewness, variance, and mean) in a single pass. This feature enhances performance \nand reduces computational overhead, making it efficient to obtain all necessary statistical\nmeasures with minimal passes through the data.\n\n**Example Usage in C**\n```C\n#include \u003cstdio.h\u003e\n#include \"incstats.h\"\n\nint main() {\n    double buffer[5] = {0}; // Initialize buffer for mean, variance, skewness, kurtosis\n    double data[20] = {5.0, 3.2, 4.1, 2.9, 6.5, 4.3, 5.1, 3.8, 4.6, 2.7, \n                       3.3, 5.7, 4.9, 2.4, 3.6, 5.8, 4.0, 6.2, 3.4, 5.3};\n    double w = 1.0;\n\n    // Update statistics with new values\n    for (int i = 0; i \u003c 20; ++i) {\n        incstats_kurtosis(data[i], w, buffer);  // This will also update mean, variance, and skewness\n    }\n\n    // Finalize and get results\n    double results[4];\n    incstats_kurtosis_finalize(results, buffer);\n\n    printf(\"Mean: %f\\n\", results[0]);\n    printf(\"Variance: %f\\n\", results[1]);\n    printf(\"Skewness: %f\\n\", results[2]);\n    printf(\"Kurtosis: %f\\n\", results[3]);\n\n    return 0;\n}\n```\n**Example Usage in C++**\n```CXX\n#include \u003ciostream\u003e // Use C++ iostream for printing\n\n// Include the C header file with extern \"C\"\nextern \"C\" {\n#include \"incstats.h\"\n}\n\nint main() {\n    double buffer[5] = {0}; // Initialize buffer for mean, variance, skewness, kurtosis\n    double data[20] = {5.0, 3.2, 4.1, 2.9, 6.5, 4.3, 5.1, 3.8, 4.6, 2.7, \n                       3.3, 5.7, 4.9, 2.4, 3.6, 5.8, 4.0, 6.2, 3.4, 5.3};\n    double w = 1.0;\n\n    // Update statistics with new values\n    for (int i = 0; i \u003c 20; ++i) {\n        incstats_kurtosis(data[i], w, buffer);  // This will also update mean, variance, and skewness\n    }\n\n    // Finalize and get results\n    double results[4];\n    incstats_kurtosis_finalize(results, buffer);\n\n    std::cout \u003c\u003c \"Mean: \" \u003c\u003c results[0] \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"Variance: \" \u003c\u003c results[1] \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"Skewness: \" \u003c\u003c results[2] \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"Kurtosis: \" \u003c\u003c results[3] \u003c\u003c std::endl;\n\n    return 0;\n}\n```\n\n## License\n\nThis project is licensed under the Apache License, Version 2.0. You may obtain a copy of the License at:\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nThe full text of the license is available in the `LICENSE.txt` file in this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborchehq%2Fincstats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborchehq%2Fincstats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborchehq%2Fincstats/lists"}