Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for MeasureBase v0.15 #122

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft

Changes for MeasureBase v0.15 #122

wants to merge 28 commits into from

Conversation

oschulz
Copy link
Collaborator

@oschulz oschulz commented Jun 29, 2023

This PR is collects changes and improvements that will become MeasureBase v0.15, hopfully early next week (there are some deadlines I need to meet). They go through individual PR's and are collected here for general comments before releasing v0.15.

CC @mschauer, @theogf

Merged pull requests: #119, #121

Major changes so far:

  • The ll-operator has been removed. There isn't an actual implementation of absolute continuity yet. We can bring this back later, one we have that.

  • PointwiseProductMeasure has been removed. It was basically the same as integration, but was described in a way limited to building posteriors.

  • New exported functions mintegrate and mintegrate_exp have been added to have function names to go with the existing and ∫exp operators.

  • The field order in Bind was changed to have the function first, as is common Julia practice.

  • bind (not exported) was renamed to mbind (exported). bind conflicts with Base.bind which has completely different semantics, and should not be used even as a non-exported function. mbind is "free" in the Julia ecosystem, and so can and should be exported, as it is a very common operation we need.

  • The rebase function was removed. It wasn't really used and one can just write mintegrate(density_rel(μ, ν), ν) directly, which is more intuitive to read.

  • The operator used for mbind (formerly bind) looks very similar to the >=> "fish" operator in functional programming (e.g. in Haskell), which is not a monadic bind but a concatenation of kernel functions. This is confusing, so we changed the operator to (which is also used in Haskell for monadic bind). Me and @cscherrer did an extensive search for suitable alternatives and settled on the as a replacement.

  • The function pullback was renamed to pullbck which now exported. pullback is heavily used for AD already, and pullbck matches the existing pushfwd. * We use as the pushforward operator and as the pullback operator now.

  • The function kernelfactor was removed. It was undocumented and not used at all, so it wasn't even clear if it was part of the public API.

  • PowerWeightedMeasure and it's operator were removed. It wasn't used in MeasureBase or MeasureTheory, and we couldn't find use of it in other packages. It was also undocmented and untested and the semantics are not entirely clear, since the resulting measure seems to depend on an assumed implicit reference measure.

    @cscherrer: I like the idea of PowerWeightedMeasure, and @mschauer has found some good use for it for sampling-based likelihood approximation. But beyond the lack of tests and documentation, there's a fundamental problem we need to straighten out. The idea here was to construct a new measure by taking some existing measure's density to some power. But as always, there's the question density with respect to what? This construction is probably more reliably expressed as a power of a likelihood (which, together with a prior, can comprise a new measure). So we'll remove this code.

    @mschauer, if you need this we'll keep it, of course (though if it's not a super-frequent operation we should still remove the operator and choose a function name for it).

  • @cscherrer: We removed some code that in v0.14 allowing constraints when constucting a likelihood from a parameterized measure. I don't think anyone was using these, but I think @nignatiadis had expressed some interest. But what we had was not very expressive, and also didn't compose well. Nikos, I think you had mentioned some ideas about this - if you like, we can discuss this some more in a new issue.

  • A lot of docstring were improved, esp. on likelihoods, but also in other places.

  • All measure operators (, , , , , ∫exp, 𝒹 and log𝒹) have been moved to the submodule MeasureOperators. Operators have a high name conflict potential, this gives the user an easy way to decide of they want them in their namespace or not.

There are currently not deprecations in regard to the breaking changes, it seemed to to @cscherrer and me to make a clean cut. If you need specific deprecations, please let us know.

Still to do (should be ready very soon)

  • Add HierarchicalMeasure #120: Add a hierarchical measure type that turns a measure and a kernel into a joint measure. In the Bayesian case it turns the prior and the likelihood kernel into the joint measure over parameters and observations. It's also necessary to express hierarchical measures (esp. priors).

  • Finish transport implementation for procucts.

  • Add a Pkg extension that takes over the role of DistributionMeasures. That way, support for Distributions will become active automatically when Distributions is loaded.

@oschulz oschulz marked this pull request as draft June 29, 2023 08:37
@github-actions
Copy link

Package name latest stable
MeasureTheory.jl

@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

Patch coverage: 58.33% and project coverage change: +1.69% 🎉

Comparison is base (99bfd9f) 54.05% compared to head (ee9f1d9) 55.74%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #122      +/-   ##
==========================================
+ Coverage   54.05%   55.74%   +1.69%     
==========================================
  Files          43       41       -2     
  Lines        1221     1175      -46     
==========================================
- Hits          660      655       -5     
+ Misses        561      520      -41     
Files Changed Coverage Δ
src/MeasureBase.jl 77.77% <ø> (ø)
src/combinators/product.jl 47.31% <ø> (+0.50%) ⬆️
src/combinators/smart-constructors.jl 24.69% <ø> (-4.38%) ⬇️
src/combinators/weighted.jl 86.36% <ø> (+7.19%) ⬆️
src/parameterized.jl 0.00% <ø> (ø)
src/combinators/bind.jl 28.57% <16.66%> (+28.57%) ⬆️
src/density.jl 48.64% <43.75%> (+5.05%) ⬆️
src/combinators/likelihood.jl 11.76% <66.66%> (-4.91%) ⬇️
src/combinators/transformedmeasure.jl 75.00% <100.00%> (+4.54%) ⬆️
src/measure_operators.jl 100.00% <100.00%> (ø)
... and 1 more

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oschulz oschulz mentioned this pull request Aug 4, 2023
@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Package name latest stable
MeasureTheory.jl

Copy link

github-actions bot commented Sep 9, 2024

Package name latest stable
MeasureTheory.jl

Will be used a lot when bridging from Distributions to MeasureBase.
Unused and untested.
Not used currently.
pullback has a huge potential for naming conflickts, and pullbck is more in line with pushfwd.

Also simplify implementation of pullbck.
Bind has too much naming conflict potential with Base.bind.

The rightarrowtail operator looks very similar to the `>=>` "fish"
operator (e.g. in Haskell), which is not a monadic bind.
Removes the integral operators from MeasureBase,
to be re-introduced in the submodule MeasureOperators.

Also improves the likelihood documentation.
A rebase can easily be written explicitly.
To be re-introduced in sub-module MeasureOperators.
oschulz and others added 9 commits November 1, 2024 21:23
`mintegral` should be used instead to express posteriors.
To be reintroduced in submodule MeasureOperators
Absolute continuity is not really implemented yet.
Having the operators in a sub-module makes it easier for users to
control whether of they want them in their namespace. Operators have
a larger naming conflict potential.
Co-authored-by: Chad Scherrer <[email protected]>
Co-authored-by: Chad Scherrer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant