Skip to main content

PyREGG

pyregg

Rare-event simulation for random geometric graphs.

pyregg estimates the probability of rare events in Gilbert random geometric graphs using three estimators: Naïve Monte Carlo (NMC), Conditional Monte Carlo (CMC), and Importance Sampling (IS).

Installation

pip install pyregg

Rare Events

Module Rare Event
pyregg.ec Edge count ≤ ℓ
pyregg.md Maximum degree ≤ ℓ
pyregg.mcc Maximum connected component size ≤ ℓ
pyregg.ntg Number of triangles ≤ ℓ
pyregg.mcs Maximum clique size ≤ ℓ
pyregg.planar Graph is planar
pyregg.forest Graph is a forest (acyclic)

Quick Start

Each module is directly callable with an optional method argument ('ismc' by default). All calls return (probability, rel_variance, n_samples).

import pyregg.ec as ec

# Estimate P(EC(G(X)) ≤ 15) on [0,10]² with κ=0.3, r=1
Z, RV, n = ec(wind_len=10, kappa=0.3, int_range=1.0, level=15)
print(f"P ≈ {Z:.4e}  (relative variance {RV:.2f},  {n} samples)")
import pyregg.planar as planar

# Estimate P(G(X) is planar) on [0,10]² with κ=1.2, r=1
Z, RV, n = planar(wind_len=10, kappa=1.2, int_range=1.0)
print(f"P ≈ {Z:.4e}  (relative variance {RV:.2f},  {n} samples)")
import pyregg.forest as forest

# Estimate P(G(X) is a forest) on [0,10]² with κ=0.3, r=1
Z, RV, n = forest(wind_len=10, kappa=0.3, int_range=1.0)
print(f"P ≈ {Z:.4e}  (relative variance {RV:.2f},  {n} samples)")

API

Calling a module

module(wind_len, kappa, int_range, [level,] method='ismc', **kwargs)

method selects the estimator: 'ismc' (Importance Sampling, default), 'cmc' (Conditional Monte Carlo), or 'nmc' (Naïve Monte Carlo). **kwargs are forwarded to the chosen estimator (e.g. grid_res, tol).

The three estimators are also available as named functions: module.naive_mc(...), module.conditional_mc(...), module.importance_sampling(...).

Common parameters

Parameter Description
wind_len Side length of the square window [0, wind_len]²
kappa Intensity of the Poisson point process (points per unit area)
int_range Connection radius — two points are connected if their distance ≤ int_range
level Threshold ℓ (not used for planar or forest)
method Estimator: 'ismc' (default), 'cmc', or 'nmc'
grid_res IS grid cells per interaction-range interval; total cells = (wind_len / int_range × grid_res)² (IS only, default 10)
max_iter Maximum number of samples (default 10⁸)
warm_up Minimum samples before checking convergence
tol Stop when relative variance / n < tol (default 0.001)

Estimators

'ismc' (default) — Sequential point addition with cells that would violate the rare event blocked; likelihood-ratio correction ensures unbiasedness.

'cmc' — Sequential point addition with analytic conditioning at each step.

'nmc' — Independent realisations; fraction satisfying the rare event.

Dependencies

Python  >= 3.10
NumPy   >= 1.24
SciPy   >= 1.10
Numba   >= 0.57
NetworkX >= 3.0

References

Metadata

Release files for pyregg 0.2.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyregg 0.2.12
File Size Uploaded Provenance
pyregg-0.2.12.tar.gz 28.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyregg 0.2.12
File Interpreter ABI Platform
pyregg-0.2.12-py3-none-any.whl Python 3 none any Details

Total release size: 79.9 kB

Release files / pyregg-0.2.12.tar.gz

Download URL pyregg-0.2.12.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e85b18f2f18c869b95163a507aa9d3b48fd0dc6ab1eee9d730f58074f3a80280
BLAKE2b-256 checksum
How to use checksums
56f217ba812f253a6c51e5cb51540a6800863cd6a77ff2d93d93a2d7cd215b08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release files / pyregg-0.2.12-py3-none-any.whl

Download URL pyregg-0.2.12-py3-none-any.whl
Size 51.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3ca190c40029e289deb476dedb5897dcc6f8a90885d032d35df614b9be3b28e
BLAKE2b-256 checksum
How to use checksums
0830dd4c2e3ee1f2de74ac4ff001c29b37d4068ff611812197534143a85baf02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Security for pyregg 0.2.12

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page