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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

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

All modified and coverable lines are covered by tests ✅

Project coverage is 97.28%. Comparing base (d59a096) to head (f9beac2).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
+ Coverage   96.69%   97.28%   +0.58%     
==========================================
  Files          25       28       +3     
  Lines         333      405      +72     
==========================================
+ Hits          322      394      +72     
  Misses         11       11              

☔ 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

@ismailsenoz
Copy link
Contributor

Is there an ETA on this one?

@Nimrais Nimrais marked this pull request as ready for review February 7, 2025 12:02
@Nimrais
Copy link
Member Author

Nimrais commented Feb 7, 2025

@ismailsenoz I think there are nuances, but more or less all things are addressed.

I don't want to change the partial code for now, I will think about how to do it properly when I address a review for Juliacon, implementing all ideas from this PR but generically for all exponential families.

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