Giter Site home page Giter Site logo

Comments (4)

jfb-h avatar jfb-h commented on June 3, 2024 1

Amazing, thanks for the quick fix @cscherrer .

from measuretheory.jl.

cscherrer avatar cscherrer commented on June 3, 2024

Thanks for the detailed description! We definitely need to get this one straightened out. I'll have a look now, not sure yet if it will be a quick fix or require refactoring.

from measuretheory.jl.

cscherrer avatar cscherrer commented on June 3, 2024

Just some notes...

I'm getting d to be

For{Normal{(:μ, :σ), Tuple{Float64, Float64}}}((x, y)->Main.Normal(x, y),
                                               ([0.888615, 0.546949, 0.480678], [0.324695, 0.232562, 0.34126]))

which is probably just differences in type inference across Julia versions. We use Core.Compiler.return_type to help figure out the element type. The result is used for acceleration and shouldn't affect the values (if it does it's a bug).

Then, note that logdensity_def works just fine:

julia> x = rand(d)
3-element Vector{Float64}:
 0.9987010201210617
 0.8059743752497901
 0.693856750735474

julia> logdensity_def(d, x)
-0.8728541665838293

The problem really comes up in iterating through basemeasures:

julia> basemeasure(d)
0.06349 * For{Union{}}(#13, ([0.888615, 0.546949, 0.480678], [0.324695, 0.232562, 0.34126]))

julia> basemeasure(ans)
For{Union{}}(#13, ([0.888615, 0.546949, 0.480678], [0.324695, 0.232562, 0.34126]))

julia> basemeasure(ans)
ERROR: MethodError: no method matching (::MeasureTheory.var"#13#14"{For{Normal{(, ), Tuple{Float64, Float64}}, var"#9#10", Tuple{Vector{Float64}, Vector{Float64}}}})(::Float64, ::Float64)
Closest candidates are:
  (::MeasureTheory.var"#13#14")(::Any) at ~/git/MeasureTheory.jl/src/combinators/for.jl:121
Stacktrace:
 [1] basemeasure(d::For{Union{}, MeasureTheory.var"#13#14"{For{Normal{(, ), Tuple{Float64, Float64}}, var"#9#10", Tuple{Vector{Float64}, Vector{Float64}}}}, Tuple{Vector{Float64}, Vector{Float64}}})
   @ MeasureTheory ~/git/MeasureTheory.jl/src/combinators/for.jl:100
 [2] top-level scope
   @ REPL[23]:1

from measuretheory.jl.

cscherrer avatar cscherrer commented on June 3, 2024

It seems to be an issue with splatting. The fix is to change this code in for.jl

    base = For(d.inds) do j
        basemeasure(d.f(j)).base
    end

to

    f(args...) = basemeasure(d.f(args...)).base
    base = For(f, d.inds...)

from measuretheory.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.