Skip to content

Port ComplexAngularCentralGaussianDistribution from libDirectional MATLAB#1649

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/port-complex-angular-central-gaussian
Draft

Port ComplexAngularCentralGaussianDistribution from libDirectional MATLAB#1649
Copilot wants to merge 2 commits intomainfrom
copilot/port-complex-angular-central-gaussian

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

Summary

Ports ComplexAngularCentralGaussian.m from libDirectional to Python as ComplexAngularCentralGaussianDistribution.

Changes

New file: pyrecest/distributions/hypersphere_subset/complex_angular_central_gaussian_distribution.py

Implements the Complex Angular Central Gaussian distribution on the complex unit hypersphere C^d (equivalently S^{2d-1} in R^{2d}), parameterized by a Hermitian positive definite matrix C of shape (d, d).

  • __init__(C): validates C is Hermitian (using allclose), stores parameter matrix and dimension
  • pdf(za): evaluates gamma(d)/(2·π^d) · |z^H C^{-1} z|^{-d} / det(C) for each row of za (shape n×d complex). Uses exp(gammaln(d) - log(2) - d·log(π)) for numerical stability
  • sample(n): generates samples via lower Cholesky factorization (C = L L^H), draws from CN(0, C), then normalizes to the complex unit sphere
  • fit(Z, n_iterations=100) (static): fits the distribution to observed unit vectors using estimate_parameter_matrix
  • estimate_parameter_matrix(Z, n_iterations=100) (static): fixed-point EM-style iterations: C ← (1/N) Σ_k weights_k z_k z_k^H where weights_k = (d-1) / |z_k^H C^{-1} z_k|

Updated: pyrecets/distributions/__init__.py

Added import and __all__ entry for ComplexAngularCentralGaussianDistribution.

New test file: pyrecets/tests/distributions/test_complex_angular_central_gaussian_distribution.py

10 tests covering:

  • Constructor validation (accepts Hermitian, rejects non-Hermitian)
  • PDF correctness: for C=I, pdf is uniform (γ(d)/(2π^d)) on the complex unit sphere (tested for d=2 and d=3)
  • PDF positivity and consistency between batch and single-vector evaluation
  • Sampling: correct shape and unit norms
  • Parameter estimation: fitted C approximately recovers identity when data is uniform
  • fit() returns correct type and dimension

Copilot AI and others added 2 commits April 6, 2026 06:02
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 9.42s
✅ JSON prettier 2 0 0 0 0.4s
✅ JSON v8r 2 0 0 2.13s
✅ MARKDOWN markdownlint 1 0 0 0 0.62s
✅ MARKDOWN markdown-table-formatter 1 0 0 0 0.29s
✅ PYTHON bandit 288 0 0 3.69s
✅ PYTHON black 288 7 0 0 5.63s
✅ PYTHON flake8 288 0 0 2.09s
✅ PYTHON isort 288 11 0 0 0.56s
✅ PYTHON mypy 288 0 0 4.23s
✅ PYTHON pylint 288 0 0 83.3s
✅ PYTHON ruff 288 11 0 0 0.05s
✅ REPOSITORY checkov yes no no 22.15s
✅ REPOSITORY gitleaks yes no no 4.26s
✅ REPOSITORY git_diff yes no no 0.04s
✅ REPOSITORY secretlint yes no no 6.62s
✅ REPOSITORY syft yes no no 3.06s
✅ REPOSITORY trivy-sbom yes no no 1.67s
✅ REPOSITORY trufflehog yes no no 17.88s
✅ YAML prettier 4 0 0 0 0.49s
✅ YAML v8r 4 0 0 4.85s
✅ YAML yamllint 4 0 0 0.44s

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 Apr 6, 2026

Test Results

   12 files     12 suites   4h 41m 14s ⏱️
  745 tests   745 ✅     0 💤 0 ❌
9 224 runs  7 720 ✅ 1 504 💤 0 ❌

Results for commit 31dd8aa.

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