{"id":19203164,"url":"https://github.com/dilawar/is_bimodal","last_synced_at":"2025-07-11T05:41:11.638Z","repository":{"id":261846154,"uuid":"885514596","full_name":"dilawar/is_bimodal","owner":"dilawar","description":"(experimental) Checks if a given histogram is bimodal using Van der Eijk's A-score","archived":false,"fork":false,"pushed_at":"2024-11-09T02:44:11.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T05:44:57.347Z","etag":null,"topics":["bimodal","rust","statistics"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dilawar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-11-08T18:27:08.000Z","updated_at":"2024-11-11T18:54:16.000Z","dependencies_parsed_at":"2024-11-08T19:42:33.775Z","dependency_job_id":null,"html_url":"https://github.com/dilawar/is_bimodal","commit_stats":null,"previous_names":["dilawar/is_bimodal"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dilawar/is_bimodal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilawar%2Fis_bimodal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilawar%2Fis_bimodal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilawar%2Fis_bimodal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilawar%2Fis_bimodal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dilawar","download_url":"https://codeload.github.com/dilawar/is_bimodal/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilawar%2Fis_bimodal/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264740552,"owners_count":23656783,"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":["bimodal","rust","statistics"],"created_at":"2024-11-09T12:47:13.723Z","updated_at":"2025-07-11T05:41:11.558Z","avatar_url":"https://github.com/dilawar.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Check bimodality of a histogram using `van_der_eijk` function.\n\n## Limiations\n\n-   The first half of the histogram should not not be too heavy (\u003e2x) or way too\n    light (\u003c0.5x) of the second half of the histogram i.e. if you sum first half\n    of the histogram and second half of the histogram, either of them should not\n    be more than twice the value than the other.\n-   The peaks of the bimodal histogram must be at the start and end.\n\n# Usage\n\nThis library provides two functions for both Rust and Python.\n\n-   `van_der_eijk` returns A-score as described in [1]. If it is less than 0.0,\n    the distribution is very likely bimodal.\n-   `is_histogram_bimodal` is a wrapper on `van_der_eijk` function and it\n    returns `True` if histogram is bimodal.\n\n## Python\n\nHere are some run on small histogram. This library typically performs much\nbetter on larger histogram.\n\n```bash\n\u003e\u003e\u003e is_bimodal.van_der_eijk([3, 1, 3])  # A-score (negative means bimodal)\n-0.14285714285714285\n\u003e\u003e\u003e is_bimodal.is_histogram_bimodal([3, 1, 3])\nTrue\n\u003e\u003e\u003e\u003e\u003e is_bimodal.is_histogram_bimodal([3, 2, 3])  # the peaks are not very high\nFalse\n\u003e\u003e\u003e is_bimodal.is_histogram_bimodal([3, 2, 4])\nFalse\n\u003e\u003e\u003e is_bimodal.is_histogram_bimodal([4, 2, 2, 4])\nFalse\n\u003e\u003e\u003e is_bimodal.is_histogram_bimodal([4, 1, 2, 4])\nTrue\n```\n\nSee \u003cpython/tests/test_is_bimodal.py\u003e. It has some test cases where the method works\npoorly.\n\n\n## Rust\n\nHere are some examples from unit tests.\n\n```\nassert!(van_der_eijk(vec![30, 40, 210, 130, 530, 50, 10]) \u003e 0.0);\nassert!(van_der_eijk(vec![30, 40, 210, 10, 530, 50, 10]) \u003e 0.0);\nassert!(van_der_eijk(vec![30, 40, 10, 10, 30, 50, 100]) \u003e 0.0);\nassert!(van_der_eijk(vec![3, 4, 1, 1, 3, 5, 10]) \u003e 0.0);\nassert!(van_der_eijk(vec![3, 4, 1, 1, 3, 5, 1]) \u003e 0.0);\nassert!(van_der_eijk(vec![1, 1, 1, 1, 1, 1, 1]) \u003e 0.0);\nassert!(van_der_eijk(vec![1, 1, 1, 1, 1, 1, 1000]) \u003e 0.0);\n\n// bimodal and detected as bimodal.\nassert!(van_der_eijk(vec![10000, 1, 1, 1, 1, 1, 10]) \u003c 0.0);\nassert!(van_der_eijk(vec![10, 10, 0, 0, 0, 10, 10]) \u003c 0.0);\nassert!(van_der_eijk(vec![10, 10, 0, 0, 0, 0, 10]) \u003c 0.0);\nassert!(van_der_eijk(vec![1, 1, 1, 0, 0, 1, 1]) \u003c 0.0);\nassert!(van_der_eijk(vec![1, 1, 1, 0, 1, 1, 1]) \u003c 0.0);\n\n// Test cases that bring the limitations of the algorithm.\n// This should be bi-modal. Algo fails because weights are not balanced here.\n// One side of the see-saw is 2x heavier.\nassert!(van_der_eijk(vec![10, 11, 0, 0, 0, 0, 3, 3]) \u003e 0.0);\nassert!(van_der_eijk(vec![10, 11, 0, 0, 0, 0, 30, 31]) \u003e 0.0);\nassert!(van_der_eijk(vec![10, 11, 0, 0, 0, 0, 20, 11]) \u003c 0.0);\n```\n\n# References\n\n[1] Eijk, Cees. (2001). Measuring Agreement in Ordered Rating Scales. Quality\nand Quantity. 35. 325-341. 10.1023/A:1010374114305.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilawar%2Fis_bimodal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdilawar%2Fis_bimodal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilawar%2Fis_bimodal/lists"}