Port ComplexWatsonDistribution and BayesianComplexWatsonMixtureModel from MATLAB#1648
Draft
Port ComplexWatsonDistribution and BayesianComplexWatsonMixtureModel from MATLAB#1648
Conversation
…from MATLAB Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/3f0bd299-8203-4bff-91e8-b8e62be085a8 Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
…up mask evaluation Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/3f0bd299-8203-4bff-91e8-b8e62be085a8 Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
FlorianPfaff
April 6, 2026 05:59
View session
❌MegaLinter analysis: Error
Detailed Issues❌ PYTHON / flake8 - 3 errors❌ PYTHON / pylint - 15 errors❌ PYTHON / ruff - 3 errorsSee 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
|
Test Results 12 files 12 suites 4h 43m 58s ⏱️ Results for commit 04f3df2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Ports two MATLAB files from libDirectional to Python:
ComplexWatsonDistributionDistribution on the complex unit sphere in C^D with PDF:
Key methods:
log_norm(D, kappa)— log normalisation constant using 3 numerical regimes (Taylor series / intermediate correction / asymptotic) for stabilitypdf(Z)— evaluates PDF at columns of complex matrix Zsample(n)— samples via the complex Bingham representationfit(Z)/estimate_parameters(Z)— MLE via scatter matrix eigendecomposition + hypergeometric ratio inverse (with asymptotic fallback to avoidhyp1f1overflow for large κ)BayesianComplexWatsonMixtureModelBayesian mixture model with complex Bingham priors on mode vectors and a Dirichlet prior on mixture weights. Posterior fitting uses a variational EM algorithm.
Key methods:
fit(Z, parameters)/fit_default(Z, K)— run EM and return(model, posterior)parameters_default(D, K)— default hyperparameter dictestimate_posterior(Z, parameters)— full E/M-step loopquadratic_expectation(dyadic_products, B)— E[z^H A z] under complex Bingham, via first-order moments computed by numerical differentiation of the simplex integralHelper functions (module-private):
_simplex_integral— evaluates ∫_simplex exp(Λ·s) ds via the partial-fractions formula_complex_bingham_first_order_moments— E[|z_i|^2] by numerical differentiation of the log-normalizationChanges
pyrecets/distributions/hypersphere_subset/complex_watson_distribution.py— new filepyrecets/distributions/hypersphere_subset/bayesian_complex_watson_mixture_model.py— new filepyrecets/distributions/__init__.py— exportsComplexWatsonDistributionandBayesianComplexWatsonMixtureModelpyrecets/tests/distributions/test_complex_watson_distribution.py— 14 testspyrecets/tests/distributions/test_bayesian_complex_watson_mixture_model.py— 19 testsAll 33 tests pass with no warnings.