{"id":15020430,"url":"https://github.com/filippobovo/robustats","last_synced_at":"2025-07-29T02:32:29.291Z","repository":{"id":35058830,"uuid":"200398980","full_name":"FilippoBovo/robustats","owner":"FilippoBovo","description":"Robustats is a Python library for high-performance computation of robust statistical estimators.","archived":false,"fork":false,"pushed_at":"2024-03-20T15:48:41.000Z","size":50,"stargazers_count":50,"open_issues_count":4,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T02:58:29.470Z","etag":null,"topics":["c","fast","high-performance","medcouple","mode","numpy","python-library","python3","robust-estimators","robust-statistics","weighted-median"],"latest_commit_sha":null,"homepage":"","language":"C","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/FilippoBovo.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":"2019-08-03T16:46:56.000Z","updated_at":"2024-10-29T20:56:06.000Z","dependencies_parsed_at":"2024-06-21T14:24:58.584Z","dependency_job_id":null,"html_url":"https://github.com/FilippoBovo/robustats","commit_stats":{"total_commits":42,"total_committers":5,"mean_commits":8.4,"dds":0.1428571428571429,"last_synced_commit":"80e1712ede9d40de0b1524b31247fc4233c3c01a"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FilippoBovo%2Frobustats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FilippoBovo%2Frobustats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FilippoBovo%2Frobustats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FilippoBovo%2Frobustats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FilippoBovo","download_url":"https://codeload.github.com/FilippoBovo/robustats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227972335,"owners_count":17849496,"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","fast","high-performance","medcouple","mode","numpy","python-library","python3","robust-estimators","robust-statistics","weighted-median"],"created_at":"2024-09-24T19:55:04.811Z","updated_at":"2024-12-03T18:19:41.324Z","avatar_url":"https://github.com/FilippoBovo.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Robustats\n\nRobustats is a Python library for high-performance computation of robust statistical estimators.\n\nThe functions that compute the robust estimators are [implemented in C](c) for speed and [called by Python](robustats).\n\nEstimators implemented in the library:\n\n- **Weighted Median** (temporal complexity: `O(n)`) \\[1, 2, 3\\]\n- **Medcouple** (temporal complexity: `O(n * log(n))`) [4, 5, 6, 7]\n- **Mode** (temporal complexity: `O(n * log(n))`) [8]\n\n## How to Install\n\nThis library requires Python 3.\n\nYou can install the library using Pip.\n\n```shell\npip install robustats\n```\n\nYou can also install the library directly from GitHub using the following command.\n\n```shell\npip install -e 'git+https://github.com/FilippoBovo/robustats.git#egg=robustats'\n```\n\nOtherwise, you may clone the repository, and install and test the Robustats package in the following way.\n\n```shell\ngit clone https://github.com/FilippoBovo/robustats.git\ncd robustats\npip install -e .\npython -m unittest\n```\n\n## How to Use\n\nThis is an example of how to use the Robustats library in Python.\n\n```python\nimport numpy as np\nimport robustats\n\n\n# Weighted Median\nx = np.array([1.1, 5.3, 3.7, 2.1, 7.0, 9.9])\nweights = np.array([1.1, 0.4, 2.1, 3.5, 1.2, 0.8])\n\nweighted_median = robustats.weighted_median(x, weights)\n\nprint(\"The weighted median is {}\".format(weighted_median))\n# Output: The weighted median is 2.1\n\n\n# Medcouple\nx = np.array([0.2, 0.17, 0.08, 0.16, 0.88, 0.86, 0.09, 0.54, 0.27, 0.14])\n\nmedcouple = robustats.medcouple(x)\n\nprint(\"The medcouple is {}\".format(medcouple))\n# Output: The medcouple is 0.7749999999999999\n\n\n# Mode\nx = np.array([1., 2., 2., 3., 3., 3., 4., 4., 5.])\n\nmode = robustats.mode(x)\n\nprint(\"The mode is {}\".format(mode))\n# Output: The mode is 3.0\n```\n\n## How to Contribute\n\nIf you wish to contribute to this library, please follow the patterns and style of the rest of the code.\n\nMoreover, install the Git hooks.\n\n```shell\ngit config core.hooksPath .githooks\n```\n\n\n\nTips:\n\n- In C, use `malloc` to allocate memory to the heap, instead of creating arrays that allocate memory to the stack, as with large array we would incur in a [segmentation fault due to stack overflow](https://stackoverflow.com/a/1847886).\n- Avoid recursions where possible to limit the spatial complexity of the problem. In place of recursions, use loops.\n\n## References\n\n\\[1\\] [Cormen, Leiserson, Rivest, Stein - Introduction to Algorithms (3rd Edition)](https://books.google.co.uk/books?id=aefUBQAAQBAJ\u0026lpg=PR5\u0026ots=dN8rWuZQaW\u0026dq=Cormen%2C%20Leiserson%2C%20Rivest%2C%20Stein%20-%20Introduction%20to%20Algorithms\u0026lr\u0026pg=PP1#v=onepage\u0026q\u0026f=false).\n\n\\[2\\] [Cormen - Introduction to Algorithms (3rd Edition) - Instructor's Manual](https://cdn.manesht.ir/19908/Introduction%20to%20Algorithms.pdf).\n\n\\[3\\] [Weighted median on Wikipedia](https://en.wikipedia.org/wiki/Weighted_median).\n\n\\[4\\] [G. Brys; M. Hubert; A. Struyf (November 2004). \"A Robust Measure of Skewness\". *Journal of Computational and Graphical Statistics*. **13** (4): 996–1017.](https://doi.org/10.1198%2F106186004X12632)\n\n\\[5\\] [Donald B. Johnson; Tetsuo Mizoguchi (May 1978). \"Selecting The Kth Element In X + Y And X1 + X2 +...+ Xm\". *SIAM Journal on Computing*. **7** (2): 147–153.](https://doi.org/10.1137%2F0207013)\n\n\\[6\\] [Medcouple implementation in Python by Jordi Gutiérrez Hermoso.](http://inversethought.com/hg/)\n\n\\[7\\] [Medcouple on Wikipedia.](https://en.wikipedia.org/wiki/Medcouple)\n\n\\[8\\] [David R. Bickel, Rudolf Frühwirth. \"On a fast, robust estimator of the mode: Comparisons to other robust estimators with applications\", *Computational Statistics \u0026 Data Analysis*, Volume 50, Issue 12, 2006, Pages 3500-3530, ISSN 0167-9473.](https://doi.org/10.1016/j.csda.2005.07.011)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilippobovo%2Frobustats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilippobovo%2Frobustats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilippobovo%2Frobustats/lists"}