Skip to content

Port WEDistribution (Wrapped Exponential) from libDirectional#1592

Open
Copilot wants to merge 3 commits intomainfrom
copilot/port-wedistribution-module
Open

Port WEDistribution (Wrapped Exponential) from libDirectional#1592
Copilot wants to merge 3 commits intomainfrom
copilot/port-wedistribution-module

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Ports the WEDistribution (Wrapped Exponential Distribution) from libDirectional to PyRecEst, following the same conventions as WrappedLaplaceDistribution and WrappedCauchyDistribution.

New: WrappedExponentialDistribution

Single rate parameter lambda_ (> 0). Implements:

  • pdfλ·exp(-λx) / (1 - exp(-2πλ)), normalization constant pre-computed in __init__
  • trigonometric_moment(n) — closed-form: 1 / (1 - jn/λ)
  • sample(n) — inverse CDF: mod(-log(U)/λ, 2π) where U ~ Uniform(0,1)
  • entropy — analytical: 1 + log((eᵝ-1)/λ) - eᵝ/(eᵝ-1)·β where β = 2πλ
from pyrecest.distributions import WEDistribution
import numpy as np

we = WEDistribution(np.array(2.0))
we.pdf(np.array([0.5, 1.0, 2.0]))
we.sample(100)
we.entropy()

Integration

  • Exported from pyrecest.distributions as WrappedExponentialDistribution
  • WEDistribution alias added for libDirectional compatibility

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 31, 2026

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 8.1s
✅ JSON prettier 2 0 0 0 0.47s
✅ JSON v8r 2 0 0 2.68s
✅ MARKDOWN markdownlint 1 0 0 0 0.65s
✅ MARKDOWN markdown-table-formatter 1 0 0 0 0.27s
✅ PYTHON bandit 252 0 0 3.09s
✅ PYTHON black 252 1 0 0 4.38s
✅ PYTHON flake8 252 0 0 1.75s
✅ PYTHON isort 252 1 0 0 0.49s
✅ PYTHON mypy 252 0 0 4.07s
✅ PYTHON pylint 252 0 0 70.2s
✅ PYTHON ruff 252 1 0 0 0.04s
✅ REPOSITORY checkov yes no no 22.9s
✅ REPOSITORY gitleaks yes no no 4.03s
✅ REPOSITORY git_diff yes no no 0.04s
✅ REPOSITORY secretlint yes no no 6.38s
✅ REPOSITORY syft yes no no 3.28s
✅ REPOSITORY trivy-sbom yes no no 1.78s
✅ REPOSITORY trufflehog yes no no 15.91s
✅ YAML prettier 4 0 0 0 0.51s
✅ YAML v8r 4 0 0 4.67s
✅ YAML yamllint 4 0 0 0.37s

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.4.0 --custom-flavor-setup --custom-flavor-linters PYTHON_PYLINT,PYTHON_BLACK,PYTHON_FLAKE8,PYTHON_ISORT,PYTHON_BANDIT,PYTHON_MYPY,PYTHON_RUFF,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 31, 2026

Test Results

    8 files   -     4      8 suites   - 4   1h 28m 19s ⏱️ - 1h 47m 51s
  623 tests +   90    623 ✅ + 90    0 💤 ±  0  0 ❌ ±0 
5 176 runs   - 1 432  4 880 ✅  - 552  296 💤  - 880  0 ❌ ±0 

Results for commit 13eecd3. ± Comparison against base commit c3471d3.

♻️ This comment has been updated with latest results.

@FlorianPfaff
Copy link
Copy Markdown
Owner

@copilot increase tolerances of the tests to 5e-7
FAILED pyrecest/tests/distributions/test_wrapped_exponential_distribution.py::WrappedExponentialDistributionTest::test_pdf - AssertionError:
Not equal to tolerance rtol=1e-10, atol=0

Mismatched elements: 1 / 1 (100%)
Max absolute difference among violations: 2.3841858e-07
Max relative difference among violations: 1.1920888e-07
ACTUAL: array(2.000007, dtype=float32)
DESIRED: array(2.000007, dtype=float32)
FAILED pyrecest/tests/test_euclidean_sampler.py::TestGaussianSampler::test_samples_follow_gaussian_distribution - AssertionError: np.float64(0.008930226739329363) not greater than 0.05
= 2 failed, 319 passed, 232 skipped, 4

auto-merge was automatically disabled April 3, 2026 13:02

Head branch was pushed to by a user without write access

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot increase tolerances of the tests to 5e-7
FAILED pyrecest/tests/distributions/test_wrapped_exponential_distribution.py::WrappedExponentialDistributionTest::test_pdf - AssertionError:
Not eq...

Done in 13eecd3. All rtol values in the test have been updated to 5e-7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants