grecov
Efficient Neyman construction for multinomial distributions with the Greedy Coverage algorithm.
Installation
For the IPOPT optimizer (recommended for best results):
pip install grecov[ipopt]
Development
Install in editable mode with test dependencies:
pip install -e ".[test]"
After modifying C++ code in src/ext/, rebuild with:
pip install -e .
Install pre-commit hooks to run ruff and clang-format on every commit:
pip install pre-commit
pre-commit install
Usage
from grecov import multinomial_ci
result = multinomial_ci(
counts=[10, 10, 20, 60],
values=[1, 2, 3, 4],
alpha=0.05,
)
print(f"95% CI: [{result['lower']:.4f}, {result['upper']:.4f}]")
R (via reticulate)
An R package is available in r-package/ that wraps grecov using
reticulate.
Installation
# Install reticulate if needed
install.packages("reticulate")
# Install the R package from the local directory
install.packages("r-package", repos = NULL, type = "source")
# Install the grecov Python package into reticulate's Python environment
grecov::install_grecov()
Usage
library(grecov)
result <- multinomial_ci(
counts = c(10, 10, 20, 60),
values = c(1, 2, 3, 4),
alpha = 0.05
)
cat(sprintf("95%% CI: [%.4f, %.4f]\n", result$lower, result$upper))
The low-level BFS function is also available:
bfs <- grecov_bfs(
p = c(0.1, 0.1, 0.2, 0.6),
v = c(1, 2, 3, 4),
s_obs = 330,
n = 100L
)
cat(sprintf("P(S <= 330) = %.6f\n", bfs$prob_left))
Options
All parameters from the Python API are available:
result <- multinomial_ci(
counts = c(10, 10, 20, 60),
values = c(1, 2, 3, 4),
alpha = 0.10,
method = "greedy",
verbose = 1L
)
Pyodide (browser / WebAssembly)
grecov compiles to WebAssembly and runs in the browser via Pyodide.
The C++ BFS extension compiles unchanged; cyipopt is not included (the scipy
trust-constr fallback is used automatically).
Using in a webpage
The pyodide wheel is attached to each GitHub Release. The following snippet automatically fetches the latest one:
<script src="https://cdn.jsdelivr.net/pyodide/v0.27.7/full/pyodide.js"></script>
<script type="module">
const pyodide = await loadPyodide();
await pyodide.loadPackage(["micropip", "numpy", "scipy"]);
// Find and install the latest pyodide wheel from GitHub Releases
const res = await fetch("https://api.github.com/repos/louisabraham/grecov/releases/latest");
const release = await res.json();
const wheel = release.assets.find(a => a.name.includes("pyodide"));
await pyodide.runPythonAsync(`
import micropip
await micropip.install("${wheel.browser_download_url}")
`);
pyodide.runPython(`
from grecov import multinomial_ci
result = multinomial_ci(
counts=[10, 10, 20, 60],
values=[1, 2, 3, 4],
alpha=0.05,
)
print(f"95% CI: [{result['lower']:.4f}, {result['upper']:.4f}]")
`);
</script>
Building the Pyodide wheel locally
pip install pyodide-build
pyodide xbuildenv install
pyodide build
This requires the matching Emscripten version (pyodide config get emscripten_version).
Install it via emsdk and source emsdk_env.sh
before running pyodide build. The wheel is written to dist/.
Performance
Pyodide/wasm performance is on par with native CPython (~1.0x). Run the comparison benchmark with:
python profiling/bench_pyodide.py
Metadata
Release files for grecov 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| grecov-0.2.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 | Details |
| grecov-0.2.3-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.24+ ARM64, Linux glibc 2.28+ ARM64 | Details |
| grecov-0.2.3-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| grecov-0.2.3-cp312-cp312-macosx_10_13_x86_64.whl | CPython 3.12 | CPython 3.12 | macOS 10.13+ x86-64 | Details |
Total release size: 273.9 kB
Release files / grecov-0.2.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | grecov-0.2.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 66.0 kB |
| Tags | CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
37efc7f12d18431e42f8dc621d105cf72fffb7d98035037857815510c2673432
|
|
BLAKE2b-256 checksum How to use checksums |
de8df7f99eb30bf9f78b3ef9f5b488b693ee808632259656259b13e5a22e1788
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / grecov-0.2.3-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
| Download URL | grecov-0.2.3-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 63.4 kB |
| Tags | CPython 3.12 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
b6f5d20a46cd605623de45f99a6e95bffd3f82c203a0b128653e1966339690a7
|
|
BLAKE2b-256 checksum How to use checksums |
92980dca4177a3b87bcb23eb3e925277dd86dc201bfb873fe1076cf1384453ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / grecov-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | grecov-0.2.3-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 67.8 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1d0e8c13ccd1d8c87f0f587382be3444bed743f22b76020bda34f560406eacc7
|
|
BLAKE2b-256 checksum How to use checksums |
ab7dd32aea6f66d28b722016bd0ad02fb870b6918d5590d4085a3c872304dbc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / grecov-0.2.3-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | grecov-0.2.3-cp312-cp312-macosx_10_13_x86_64.whl |
|---|---|
| Size | 76.6 kB |
| Tags | CPython 3.12 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
47ceb1f0a0b99ae620528c492416add9f8e1fdbebe296b3f8beba152b71a10c0
|
|
BLAKE2b-256 checksum How to use checksums |
284b17055822587a984a1b8bc61da24d8dd5180dda554113f5450572a55afa0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logSecurity for grecov 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for grecov-0.2.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.