Skip to content

Conversation

penelopeysm
Copy link
Member

@penelopeysm penelopeysm commented Oct 17, 2025

Closes #388.

  • Implement for simple cases
  • Make it type stable
  • Handle nested ProductNamedTupleDistribution
  • Implement logabsdetjac
julia> using Bijectors

julia> d = product_distribution((a=Normal(), b=LogNormal()))
ProductNamedTupleDistribution{(:a, :b)}(
a: Normal{Float64}=0.0, σ=1.0)
b: LogNormal{Float64}=0.0, σ=1.0)
)


julia> b = bijector(d)
Bijectors.NamedStacked{(:a, :b), @NamedTuple{a::typeof(identity), b::Base.Fix1{typeof(broadcast), typeof(log)}}, @NamedTuple{a::Int64, b::Int64}}((a = identity, b = Base.Fix1{typeof(broadcast), typeof(log)}(broadcast, log)), (a = 1, b = 2))

julia> x = rand(d)
(a = -0.2857657609237111, b = 1.7017383063757614)

julia> y = transform(b, x)
2-element Vector{Float64}:
 -0.2857657609237111
  0.5316502617934541

julia> x2 = transform(binv, y)
(a = -0.2857657609237111, b = 1.7017383063757614)

@penelopeysm penelopeysm marked this pull request as draft October 17, 2025 14:24
@github-actions
Copy link
Contributor

Bijectors.jl documentation for PR #418 is available at:
https://TuringLang.github.io/Bijectors.jl/previews/PR418/

@penelopeysm penelopeysm changed the title Support ProductNamedTupleDistribution Support ProductNamedTupleDistribution, export output_size Oct 17, 2025
@penelopeysm penelopeysm marked this pull request as ready for review October 17, 2025 15:52
Copy link
Member

@sunxd3 sunxd3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me.

One concern is that transformed(d) won't work at the moment because it still uses Base.size but I don't mind push this later if keen to merge.

@penelopeysm
Copy link
Member Author

Ooh, okay. I am not sure how to implement that, let me look at it

@penelopeysm penelopeysm requested a review from sunxd3 October 20, 2025 12:57
@penelopeysm
Copy link
Member Author

Thanks @sunxd3!

@penelopeysm penelopeysm merged commit 3334fc5 into main Oct 20, 2025
15 checks passed
@penelopeysm penelopeysm deleted the py/productnamedtuple branch October 20, 2025 16:21
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.

Support ProductNamedTupleDistribution

2 participants