{"id":18016271,"url":"https://github.com/egarpor/sphunif","last_synced_at":"2025-03-26T18:32:09.077Z","repository":{"id":47510406,"uuid":"290071903","full_name":"egarpor/sphunif","owner":"egarpor","description":"Implementation of uniformity tests on the circle and (hyper)sphere, with a C++ core. The package allows the replication of the data application in \"On a projection-based class of uniformity tests on the hypersphere\"","archived":false,"fork":false,"pushed_at":"2024-06-20T20:17:59.000Z","size":2680,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-30T06:12:11.587Z","etag":null,"topics":["circular-statistics","directional-statistics","r","uniformity","uniformity-tests"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/egarpor.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","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-08-25T00:33:49.000Z","updated_at":"2024-05-24T11:26:45.000Z","dependencies_parsed_at":"2022-07-22T13:32:44.272Z","dependency_job_id":"6ba40726-5b20-402c-95f7-ff398037f6ab","html_url":"https://github.com/egarpor/sphunif","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":0.2195121951219512,"last_synced_commit":"660968402e752032537a9935f615e8f586d85651"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egarpor%2Fsphunif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egarpor%2Fsphunif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egarpor%2Fsphunif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egarpor%2Fsphunif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egarpor","download_url":"https://codeload.github.com/egarpor/sphunif/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245712974,"owners_count":20660327,"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":["circular-statistics","directional-statistics","r","uniformity","uniformity-tests"],"created_at":"2024-10-30T04:16:54.890Z","updated_at":"2025-03-26T18:32:07.996Z","avatar_url":"https://github.com/egarpor.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput:\n  md_document:\n    variant: gfm\n---\n\n```{r, setup, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE, comment = \"#\u003e\", fig.path = \"README/README-\",\n  message = FALSE, warning = FALSE, fig.asp = 1, fig.align = 'center'\n)\n```\n\nsphunif\n=======\n\n```{r, badges, echo = FALSE, results = 'asis'}\ncat(\n  badger::badge_license(license = \"GPLv3\", color = \"blue\",\n                        url = \"https://www.gnu.org/licenses/gpl-3.0\"),\n  badger::badge_github_actions(action = \"R-CMD-check\"),\n  badger::badge_github_actions(action = \"test-coverage\"),\n  badger::badge_codecov(),\n  badger::badge_cran_release(color = \"green\"),\n  badger::badge_cran_download(pkg = NULL, type = \"grand-total\"),\n  badger::badge_cran_download(pkg = NULL, type = \"last-month\")\n)\n```\n\n\u003c!-- \u003cimg src=\"\" alt=\"sphunif hexlogo\" align=\"right\" width=\"200\" style=\"padding: 0 15px; float: right;\"/\u003e --\u003e\n\n## Overview\n\nImplementation of more than 35 tests of uniformity on the circle, sphere, and hypersphere. Software companion for the (evolving) review *An overview of uniformity tests on the hypersphere* (García-Portugués and Verdebout, 2018) and the paper *On a projection-based class of uniformity tests on the hypersphere* (García-Portugués, Navarro-Esteban and Cuesta-Albertos, 2023).\n\n## Installation\n\nGet the latest version from GitHub:\n\n```{r, install-devtools, eval = FALSE}\n# Install the package and the vignettes\nlibrary(devtools)\ninstall_github(\"egarpor/sphunif\", build_vignettes = TRUE)\n\n# Load package\nlibrary(sphunif)\n\n# See main vignette\nvignette(\"sphunif\")\n```\n\n```{r, load, echo = FALSE}\n# Load package\nlibrary(sphunif)\n```\n\n## Usage\n\n### Circular data\n\nYou want to test if a sample of *circular* data is uniformly distributed. For example, the following circular uniform sample in *radians*:\n\n```{r, cir_data}\nset.seed(987202226)\ncir_data \u003c- runif(n = 10, min = 0, max = 2 * pi)\n```\n\nCall the main function in the `sphunif` package, `unif_test`, specifying the `type` of test to be performed. For example, the `\"Watson\"` test:\n\n```{r, unif_test_cir}\nlibrary(sphunif)\nunif_test(data = cir_data, type = \"Watson\") # An htest object\n```\n\nBy default, the calibration of the test statistic is done by Monte Carlo. This can be changed with `p_value = \"asymp\"` to employ asymptotic distributions (faster, but not available for all tests):\n\n```{r, asymp}\nunif_test(data = cir_data, type = \"Watson\", p_value = \"MC\") # Monte Carlo\nunif_test(data = cir_data, type = \"Watson\", p_value = \"asymp\") # Asymp. distr.\n```\n\nYou can perform *several* tests with a *single* call to `unif_test`. Choose the available circular uniformity tests from\n\n```{r, avail_cir}\navail_cir_tests\n```\n\nFor example:\n\n```{r, unif_test_avail_cir}\n# A *list* of htest objects\nunif_test(data = cir_data, type = c(\"Watson\", \"PAD\", \"Ajne\"))\n```\n\n### Spherical data\n\nYou want to test if a sample of *spherical* data is uniformly distributed. Consider a *non*-uniformly-generated sample of directions in **Cartesian coordinates**:\n\n```{r, sph_data}\n# Sample data on S^2\nset.seed(987202226)\ntheta \u003c- runif(n = 50, min = 0, max = 2 * pi)\nphi \u003c- runif(n = 50, min = 0, max = pi)\nsph_data \u003c- cbind(cos(theta) * sin(phi), sin(theta) * sin(phi), cos(phi))\n```\n\nThe available spherical uniformity tests:\n\n```{r, avail_sph}\navail_sph_tests\n```\n\nThe default `type = \"all\"` equals `type = avail_sph_tests`:\n\n```{r, unif_test_avail_sph}\nhead(unif_test(data = sph_data, type = \"all\", p_value = \"MC\"))\nunif_test(data = sph_data, type = \"Rayleigh\", p_value = \"asymp\")\n```\n\n### Higher dimensions\n\nThe *hyperspherical* setting is treated analogously to the spherical setting, and the available tests are exactly the same (`avail_sph_tests`). An example of testing uniformity with a sample of size `100` on the $9$-sphere:\n\n```{r, hyp_data}\n# Sample data on S^9\nset.seed(987202226)\nhyp_data \u003c- r_unif_sph(n = 50, p = 10)\n\n# Test\nunif_test(data = hyp_data, type = \"Rayleigh\", p_value = \"asymp\")\n```\n\n## Replicability\n\n### *On a projection-based class of uniformity tests on the hypersphere*\n\nThe data application in García-Portugués, Navarro-Esteban, and Cuesta-Albertos (2023) regarding the testing of uniformity of locations for craters in Rhea can be reproduced through the script [data-application-ecdf.R](https://github.com/egarpor/sphunif/blob/master/applications/data-application-ecdf.R). The code snippet below is a simplified version.\n\n```{r, rhea}\n# Load data\ndata(rhea)\n\n# Add Cartesian coordinates\nrhea$X \u003c- cbind(cos(rhea$theta) * cos(rhea$phi),\n                sin(rhea$theta) * cos(rhea$phi),\n                sin(rhea$phi))\n\n# Distribution of diameter\nquantile(rhea$diameter)\n\n# Subsets of craters, according to diameter\nind_15_20 \u003c- rhea$diameter \u003e 15 \u0026 rhea$diameter \u003c 20\nind_20 \u003c- rhea$diameter \u003e 20\n\n# Sample sizes\nnrow(rhea)\nsum(ind_15_20)\nsum(ind_20)\n\n# Tests to be performed\ntype_tests \u003c- c(\"PCvM\", \"PAD\", \"PRt\")\n\n# Tests\ntests_rhea_15_20 \u003c- unif_test(data = rhea$X[ind_15_20, ], type = type_tests,\n                              p_value = \"asymp\", K_max = 5e4)\ntests_rhea_20 \u003c- unif_test(data = rhea$X[ind_20, ], type = type_tests,\n                           p_value = \"asymp\", K_max = 5e4)\ntests_rhea_15_20\ntests_rhea_20\n```\n\n### *A Cramér–von Mises test of uniformity on the hypersphere*\n\nThe data application in García-Portugués, Navarro-Esteban, and Cuesta-Albertos (2021) regarding the testing of the uniformity of locations for craters in Venus can be reproduced through the script [data-application-cvm.R](https://github.com/egarpor/sphunif/blob/master/applications/data-application-cvm.R).\n\n### *On a class of Sobolev tests for symmetry of directions, their detection thresholds, and asymptotic powers*\n\nThe data application in García-Portugués, Paindaveine, and Verdebout (2024) regarding the symmetry of comet orbits can be reproduced through the script [data-application-sobolev.R](https://github.com/egarpor/sphunif/blob/master/applications/data-application-sobolev.R).\n\n### *A stereographic test of spherical uniformity*\n\nThe script [simulations-stereo.R](https://github.com/egarpor/sphunif/blob/master/simulations/simulations-stereo.R) contains some of the numerical experiments in Fernández-de-Marcos and García-Portugués (2024).\n\n## References\n\nFernández-de-Marcos, A. and García-Portugués, E. (2024). A stereographic test of spherical uniformity. *arXiv:2405.13531*. [doi:10.48550/arXiv.2405.13531](https://doi.org/10.48550/arXiv.2405.13531).\n\nGarcía-Portugués, E., Navarro-Esteban, P., and Cuesta-Albertos, J. A. (2023). On a projection-based class of uniformity tests on the hypersphere. *Bernoulli*, 29(1):181--204. [doi:10.1007/978-3-030-69944-4_12](https://doi.org/10.3150/21-BEJ1454).\n\nGarcía-Portugués, E., Navarro-Esteban, P., and Cuesta-Albertos, J. A. (2021). A Cramér–von Mises test of uniformity on the hypersphere. In Balzano, S., Porzio, G. C., Salvatore, R., Vistocco, D., and Vichi, M. (Eds.), *Statistical Learning and Modeling in Data Analysis*, Studies in Classification, Data Analysis and Knowledge Organization, pp. 107--116. Springer, Cham. [doi:10.1007/978-3-030-69944-4_12](https://doi.org/10.1007/978-3-030-69944-4_12).\n\nGarcía-Portugués, E., Paindaveine, D., and Verdebout, T. (2024). On a class of Sobolev tests for symmetry of directions, their detection thresholds, and asymptotic powers. *arXiv:2108.09874v2*. [doi:10.48550/arXiv.2108.09874](https://doi.org/10.48550/arXiv.2108.09874).\n\nGarcía-Portugués, E. and Verdebout, T. (2018). An overview of uniformity tests on the hypersphere. *arXiv:1804.00286*. [doi:10.48550/arXiv.1804.00286](https://doi.org/10.48550/arXiv.1804.00286).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegarpor%2Fsphunif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegarpor%2Fsphunif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegarpor%2Fsphunif/lists"}