JuliaMath / JuliaMath/MeasureTheory.jl

Use `⊙` instead of `*` for creating weighted measures?

Open
#170 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
401
Forks
31
PR merge metrics
No merged PRs in 30d

Description

@keorn pointed out that in Distributions, `*` and `+` behave like this:
```julia
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
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
```julia
density(k * μ) = k * density(μ)
```
Under this change, this would become
```julia
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)`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.