Adds mass and normalize for a measure
Fixes #128
Codecov Report
Merging #130 (111779b) into master (8a2c551) will decrease coverage by
0.23%. The diff coverage is0.00%.
@@ Coverage Diff @@
## master #130 +/- ##
==========================================
- Coverage 33.96% 33.73% -0.24%
==========================================
Files 50 51 +1
Lines 998 1005 +7
==========================================
Hits 339 339
- Misses 659 666 +7
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/MeasureTheory.jl | 50.00% <ø> (ø) |
|
| src/combinators/weighted.jl | 12.90% <0.00%> (-0.44%) |
:arrow_down: |
| src/distributions.jl | 0.00% <0.00%> (ø) |
|
| src/mass.jl | 0.00% <0.00%> (ø) |
|
| src/primitives/dirac.jl | 18.75% <0.00%> (-1.25%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 8a2c551...111779b. Read the comment docs.
Hey there @sethaxen! I wanted to do that too in order to simulate Poisson processes on a given set, but I was going to make the relevant measures callable: something like
(::Lebesgue{ℝ})(interval::IntervalSets.AbstractInterval) = duration(interval)
Is that compatible with your approach? If not, which do you think is best?
After some more thinking, I feel like it the notion of total mass is intimately linked with the subset we consider. If we want to integrate (numerically) a measure on a set, do we define the measure on that set (as in Lebesgue(S)) or do we apply the measure to that set (as in (::Lebesgue)(S)) ? I think the second one makes more sense, but I would like @cscherrer's input
The purpose of this PR was to provide an easy way to normalize a measure, but I don't think this is the right approach. For example, suppose we have a measure μ that we want to normalize, and we know how to sample from the normalized measure, but we don't know the total mass. Then this approach will not work, since it relies on computing the total mass.
I've been experimenting with a Normalized measure that simply represents the normalized version of whatever measure it wraps: https://github.com/JuliaManifolds/ManifoldMeasures.jl/blob/main/src/normalized.jl You can see, for example, how it is used here: https://github.com/JuliaManifolds/ManifoldMeasures.jl/blob/55f1713df5257c0723c6f3ff09d51e985777bb34/src/hausdorff.jl#L140-L150. This allows us to avoid computing the logmass unless absolutely necessary.
After some more thinking, I feel like it the notion of total mass is intimately linked with the subset we consider. If we want to integrate (numerically) a measure on a set, do we define the measure on that set (as in
Lebesgue(S)) or do we apply the measure to that set (as in(::Lebesgue)(S)) ? I think the second one makes more sense, but I would like @cscherrer's input
I completely agree that for computing mass in general, we need a generic way to define sets, and it would be nice to be able to flexible hook into numerical integration packages for that. But because something like logmass could be called deep in some user code, we need to find a way for that user to specify parameters of the numerical integration algorithm.
Yes, I think these are two different things. For a measure μ, I think it makes sense to ask for μ(S) for some set S. For a point process, S might be a Set (if we have exchangability), or maybe an iterable.
Otherwise, we need to be a little restrictive, since things can get out of hand. I do think there are some things we can do for manifolds or measures dominated by Lebesgue measure, moslty in terms of intervals.
IntervalSets is very lightweight, so I think we could depend on that. Beyond that, there's lots of great stuff in JuliaIntervals that we could get to through an extension package. Those (at least mostly) don't depend on IntervalSets, but a conversion should be very easy.
So where does that leave us? I'm a bit lost as to what to implement
So where does that leave us? I'm a bit lost as to what to implement
Sounds like we collectively need to get in sync. I'll write a summary on Zulip, and we can talk some more about a broad view of where we're heading.