{"id":32158193,"url":"https://github.com/panlanfeng/gaussianmixturetest.jl","last_synced_at":"2026-02-19T02:02:32.681Z","repository":{"id":61798019,"uuid":"51405895","full_name":"panlanfeng/GaussianMixtureTest.jl","owner":"panlanfeng","description":"Implement the Kasahara-Shimotsu Test to decide number of components in Gaussian Mixture Model.","archived":false,"fork":false,"pushed_at":"2019-03-25T21:45:00.000Z","size":38,"stargazers_count":4,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T12:58:56.668Z","etag":null,"topics":["mixture-model","number-of-clusters"],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/panlanfeng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-09T22:40:16.000Z","updated_at":"2022-06-23T03:32:19.000Z","dependencies_parsed_at":"2022-10-21T11:30:54.032Z","dependency_job_id":null,"html_url":"https://github.com/panlanfeng/GaussianMixtureTest.jl","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/panlanfeng/GaussianMixtureTest.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlanfeng%2FGaussianMixtureTest.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlanfeng%2FGaussianMixtureTest.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlanfeng%2FGaussianMixtureTest.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlanfeng%2FGaussianMixtureTest.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panlanfeng","download_url":"https://codeload.github.com/panlanfeng/GaussianMixtureTest.jl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panlanfeng%2FGaussianMixtureTest.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29600848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T00:59:38.239Z","status":"online","status_checked_at":"2026-02-19T02:00:07.702Z","response_time":117,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["mixture-model","number-of-clusters"],"created_at":"2025-10-21T12:58:50.598Z","updated_at":"2026-02-19T02:02:32.675Z","avatar_url":"https://github.com/panlanfeng.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GaussianMixtureTest\n\nLinux and macOS: [![Build Status](https://travis-ci.org/panlanfeng/GaussianMixtureTest.jl.svg?branch=master)](https://travis-ci.org/panlanfeng/GaussianMixtureTest.jl)\n\nWindows: [![Build Status](https://ci.appveyor.com/api/projects/status/github/panlanfeng/GaussianMixtureTest.jl?branch=master\u0026svg=true)](https://ci.appveyor.com/project/panlanfeng/GaussianMixtureTest-jl/branch/master)\n\n\nThis package implements the EM test for number of components of univariate Gaussian Mixture. The conventional log likelihood test can not be used to test the number of components because the Fisher regularity conditions are violated in Gaussian Mixture case [1].\n\nThis package follows the method of [3] but with no regression covariates. Note that the asymptotic distribution of the test statistic is that of the maximum of `C0` dependent $Chi^2(2)$ random variables which has no closed form when the null distribution has more than 1 component. However the p value can be obtained via simulation.\n\nIn addition the typical EM algorithm may fail to give a consistent estimate of Gaussian Mixture parameters. This package still uses EM but add a penalty term on the log likelihood which ensures the consistency [2].\n\n\n## Usage\n\nTo install this package, run\n\n    Pkg.add(\"GaussianMixtureTest\")\n\nThe major functions are `gmm`, `gmmrepeat`,`asymptoticdistribution` and `kstest`. `gmm` estimates the parameters via EM algorithm. `gmmrepeat` repeat `gmm` for multiple starting values. `asymptoticdistribution` simulates the asymptotic distribution of the test statistic when the number of components is greater than 2. `kstest` conducts the Kasahara-Shimotsu test.\n\nSee also the usage by running\n\n    ?gmm\n\n\n## Examples\n\nSee the example code also in [`runtests.jl`](test/runtests.jl)\n\n    using Distributions\n    using GaussianMixtureTest\n\n    mu_true = [-2.0858,-1.4879]\n    wi_true = [0.0828,0.9172]\n    sigmas_true = [0.6735,0.2931]\n\n    m = MixtureModel(map((u, v) -\u003e Normal(u, v), mu_true, sigmas_true), wi_true)\n    x = rand(m, 1000);\n\n    asymptoticdistribution(x, wi_true, mu_true, sigmas_true, debuginfo=true);\n\n    #Estimate the parameters with two components\n    wi, mu, sigmas, ml = gmm(x, 2)\n\n    #Do the KS test for C=2 v.s. C=3\n    kstest(x, 2)\n\n## Acknowledgement\n\nThanks Dr. Shimotsu and Dr. Kasahara for nicely providing their original R code and their detailed explanations. Several implementation details of this package are borrowed from their R code.\n\n## Reference\n\n - [1] Chen, J. \u0026 Li, P., 2009. Hypothesis Test for Normal Mixture Models: The EM Approach. _the Annals of Statistics_, 37(5 A), pp.2523–2542.\n\n - [2] Chen, J., Tan, X. \u0026 Zhang, R., 2008. Inference for Normal Mixtures in Mean and Variance. _Statistica Sinica_, 18, pp.443–465.\n\n - [3] Kasahara, H. \u0026 Shimotsu, K., 2015. Testing the Number of Components in Normal Mixture Regression Models. _Journal of the American Statistical Association_ (to appear), pp.1–33.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanlanfeng%2Fgaussianmixturetest.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanlanfeng%2Fgaussianmixturetest.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanlanfeng%2Fgaussianmixturetest.jl/lists"}