MeasureBase.jl icon indicating copy to clipboard operation
MeasureBase.jl copied to clipboard

Hitting `NoTransportOrigin` from weighted measures

Open cscherrer opened this issue 1 year ago • 3 comments

The "transport origin" of a WeightedMeasure needs to be weighted. I had thought this might be easy:

transport_origin(ν::WeightedMeasure) = weightedmeasure(ν.logweight, transport_origin(ν.base))

to_origin(w::WeightedMeasure, y) = to_origin(w.base, y)
from_origin(w::WeightedMeasure, x) = from_origin(w.base, x)

but this leads us to

julia> MeasureBase.transport_origin(2.2 * StdNormal())
2.2 * MeasureBase.NoTransportOrigin{StdNormal}()

I understand that this is just how dispatch is set up for transports, but it's bitten me a few times, and I think it will be at least as confusing for new users as it has been for me. I think we can keep the current high-level functionality but change the dispatch patterns under the hood so it works more like basemeasure. That would also help new devs, because getting used to one (basemeasures or transports) will make the other easier.

@oschulz I could try to prototype this, but I know you're also working on improving type stability for transports, and I don't want us to collide more than we have to :)

cscherrer avatar Sep 29 '22 13:09 cscherrer