Skip to content

Add basemeasure method for discrete Distributions #165

Open
@cscherrer

Description

@cscherrer

@cscherrer It seems some recent changes of Soss/MeasureTheory broke the tests: https://github.com/JuliaGaussianProcesses/AbstractGPs.jl/pull/206/checks?check_run_id=3858536599#step:6:962 and https://github.com/JuliaGaussianProcesses/AbstractGPs.jl/pull/206/checks?check_run_id=3858536599#step:6:1068. Tests passed on the master branch two weeks ago. Maybe it's related to cscherrer/Soss.jl#305?

Originally posted by @devmotion in JuliaGaussianProcesses/AbstractGPs.jl#206 (comment)

FWIW this passes:
https://gist.github.com/cscherrer/f2788b7ab62a232eb42a3068fe2fe56c

But it looks these tests are using Distributions instead.

The problem seems to be here:

julia> using MeasureTheory

julia> basemeasure(Poisson(3))
CountingMeasure(ℤ[0:ℵ₀])

julia> basemeasure(Dists.Poisson(3))
ERROR: MethodError: no method matching basemeasure(::Distributions.Poisson{Float64})
Closest candidates are:
  basemeasure(::Pullback{TransformVariables.CallableTransform{T}, Lebesgue{ℝ}}) where T<:TransformVariables.ScalarTransform at /home/chad/git/MeasureTheory.jl/src/combinators/transforms.jl:81
  basemeasure(::Pullback) at /home/chad/git/MeasureTheory.jl/src/combinators/transforms.jl:63
  basemeasure(::SuperpositionMeasure) at /home/chad/git/MeasureBase/src/combinators/superpose.jl:48
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

The solution is to add a basemeasure method for Distributions.Discrete so Poisson can use it, i.e.

julia> typeof(Dists.Poisson(3)) |> supertype
Distributions.Distribution{Distributions.Univariate, Distributions.Discrete}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions