Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
sunxd3 and github-actions[bot] authored Aug 15, 2024
1 parent 67ff8e8 commit f758a4c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions gibbs_example/gmm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,21 @@ function condition(gmm::GMM, conditioned_values::NamedTuple)
return ConditionedGMM(gmm.data, conditioned_values)
end

function LogDensityProblems.logdensity(gmm::ConditionedGMM{names}, params::AbstractVector) where {names}
function LogDensityProblems.logdensity(
gmm::ConditionedGMM{names}, params::AbstractVector
) where {names}
if Set(names) == Set([, :w]) # conditioned on μ, w, so params are z
return log_joint(; μ=gmm.conditioned_values.μ, w=gmm.conditioned_values.w, z=params, x=gmm.data.x)
return log_joint(;
μ=gmm.conditioned_values.μ, w=gmm.conditioned_values.w, z=params, x=gmm.data.x
)
elseif Set(names) == Set([:z, :w]) # conditioned on z, w, so params are μ
return log_joint(; μ=params, w=gmm.conditioned_values.w, z=gmm.conditioned_values.z, x=gmm.data.x)
return log_joint(;
μ=params, w=gmm.conditioned_values.w, z=gmm.conditioned_values.z, x=gmm.data.x
)
elseif Set(names) == Set([:z, ]) # conditioned on z, μ, so params are w
return log_joint(; μ=gmm.conditioned_values.μ, w=params, z=gmm.conditioned_values.z, x=gmm.data.x)
return log_joint(;
μ=gmm.conditioned_values.μ, w=params, z=gmm.conditioned_values.z, x=gmm.data.x
)
else
error("Unsupported conditioning configuration.")
end
Expand Down

0 comments on commit f758a4c

Please sign in to comment.