Skip to content

Use instead of * for creating weighted measures? #170

@cscherrer

Description

@cscherrer

@keorn pointed out that in Distributions, * and + behave like this:

julia> 3 * Dists.Normal()
Distributions.LocationScale{Float64, Distributions.Continuous, Distributions.Normal{Float64}}(
μ: 0.0
σ: 3.0
ρ: Distributions.Normal{Float64}=0.0, σ=1.0)
)


julia> 3 + Dists.Normal()
Distributions.LocationScale{Float64, Distributions.Continuous, Distributions.Normal{Float64}}(
μ: 3.0
σ: 1.0
ρ: Distributions.Normal{Float64}=0.0, σ=1.0)
)

This is very different from MeasureTheory, where

julia> density(3 * Normal(), 2.4) / density(Normal(), 2.4)
3.0

This issue is to consider making some changes to this, to minimize confusion for those coming from Distributions.

We currently allow for a "likelihood operating on a measure". We could potentially consider a scalar to work in a similar way, almost like a likelihood that always returns the given value.

Notes / Concerns

Currently for any constant k and measure μ we have

density(k * μ) = k * density(μ)

Under this change, this would become

density(k  μ) = k * density(μ)

Despite its common use in Distributions, it's a little strange from a type perspective to expect this to work. It feels a little like having a function f and wanting k * f to return a new function x -> k * f(x).

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