Add PiecewiseConstantDistribution for circular distributions#1589
Add PiecewiseConstantDistribution for circular distributions#1589
Conversation
Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/63fdf26d-4651-4b25-82ef-a43575b8bf7c Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
❌MegaLinter analysis: Error
Detailed Issues❌ PYTHON / flake8 - 1 errorSee 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
|
a7e178a to
771fe82
Compare
@copilot Can you fix the linter errors below?************* Module pyrecest.distributions.circle.piecewise_constant_distribution Your code has been rated at 10.00/10pyrecest/distributions/init.py:87:1: F401 '.circle.piecewise_constant_distribution.PiecewiseConstantDistribution' imported but unused |
… pdf index bug Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/6e33f469-e06f-4f76-906e-7de00e354a5e Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Fixed in a6234b8:
Also fixed a latent bug in |

Python port of the MATLAB
PWCDistribution: a histogram-style circular distribution that divides[0, 2π)intonequal intervals, each with a constant pdf weight.New class:
PiecewiseConstantDistribution__init__(w)— accepts raw weights, auto-normalizes viaw / (mean(w) · 2π)pdf(xs)— maps each point to its interval index via modular arithmetictrigonometric_moment(n)— exact analytical formula:−i/n · Σ wⱼ(e^{inrⱼ} − e^{inlⱼ})entropy()— exact:−(2π/n) · Σ wⱼ log wⱼsample(n)— categorical sample over intervals, then uniform within the chosen intervalleft_border/right_border/interval_center— 1-indexed static helperscalculate_parameters_numerically(pdf_func, n)— fits weights by integrating any circular pdf over each interval viascipy.integrate.quadNotes
scipy.nquad, sincenquadis unreliable on piecewise-discontinuous integrands.pyrecest/distributions/__init__.py.