Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add natural gamma manifold #26

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

Nimrais
Copy link
Member

@Nimrais Nimrais commented Jan 22, 2025

No description provided.

@Nimrais Nimrais marked this pull request as draft January 22, 2025 18:22
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 96.55172% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.66%. Comparing base (d59a096) to head (9e80b86).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/normal_gamma/natural.jl 96.15% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
- Coverage   96.69%   96.66%   -0.04%     
==========================================
  Files          25       28       +3     
  Lines         333      420      +87     
==========================================
+ Hits          322      406      +84     
- Misses         11       14       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ismailsenoz
Copy link
Contributor

A more generic implementation of Christoffel symbol.

function christoffel(::Type{D}, ::NaturalParametersSpace, η) where D
    # Pre-compute values used multiple times
    ef = ExponentialFamilyDistribution(D, η, nothing)
    G = fisherinformation(ef)
    G⁻¹ = cholinv(G)
    dG = partial_metric(D, NaturalParametersSpace(), η)
    
    T = eltype(G)  # Get the element type from G
    
    # Pre-allocate output array
    rep_size = sum(representation_size(get_natural_manifold(D, size(η))))
    Γ = zeros(T, rep_size, rep_size, rep_size)
        
    # Pre-compute the sum of dG terms
    dG_sum = similar(dG)
    
    @tensor begin
        dG_sum[ℓ,j,i] = dG[ℓ,j,i] + dG[ℓ,i,j] - dG[i,j,ℓ]
    end
    
    # Use tensor operations with pre-computed sum
    @tensor begin
        Γ[k,i,j] = T(0.5) * G⁻¹[k,ℓ] * dG_sum[ℓ,j,i]
    end
    
    return Γ
end

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