Open cartazio opened 3 years ago
Hi @cartazio ,
I really like this idea. Julia has a few different interval libraries: https://github.com/JuliaIntervals
I like the ideas I've seen from @dpsanders , for example I this this package could be really helpful for this: https://github.com/JuliaIntervals/IntervalContractors.jl
The big questions I have currently are
This is a great idea.
Unfortunately there is not much compatibility right now. You may want to use your own interval type (yet another one) and then provide interfaces to the different packages if necessary.
Note that anything beyond Lebesgue measure / Dirac delta is more complicated, since in general it will need an integral over a density to be involved.
Or (better?) to express everything in terms of the [cumulative] distribution function instead.
Beyond R^n you will probably want something like https://github.com/JuliaManifolds/Manifolds.jl and work with atlases somehow?
Or what context did you have in mind?
Unfortunately there is not much compatibility right now. You may want to use your own interval type (yet another one) and then provide interfaces to the different packages if necessary.
Maybe IntervalSets? That seems intended for a use case like this.
Or (better?) to express everything in terms of the [cumulative] distribution function instead.
For one dimension, yes. I haven't thought much about how to do this in higher dimensions. I've seen people use copulas (or is it copulae?), but I haven't worked with them much.
Beyond R^n you will probably want something like https://github.com/JuliaManifolds/Manifolds.jl and work with atlases somehow?
Maybe that's the right way, I'm not sure.
Or what context did you have in mind?
Mostly I want to have something that covers the common cases and is easily extensible beyond this. So maybe nothing too opinionated beyond the core stuff
Maybe IntervalSets? That seems intended for a use case like this.
Yes, that's probably a good option since it can handle both closed and open sets, unlike IntervalArithmetic.jl.
Or (better?) to express everything in terms of the [cumulative] distribution function instead.
For one dimension, yes. I haven't thought much about how to do this in higher dimensions. I've seen people use copulas (or is it copulae?), but I haven't worked with them much.
Not my area, but looks interesting.
Beyond R^n you will probably want something like https://github.com/JuliaManifolds/Manifolds.jl and work with atlases somehow?
Maybe that's the right way, I'm not sure.
Or what context did you have in mind?
Mostly I want to have something that covers the common cases and is easily extensible beyond this. So maybe nothing too opinionated beyond the core stuff
Maybe you literally want a SigmaAlgebra
type for finite unions (so I guess just an Algebra
, though now I'm really struggling to remember my measure theory course from aeons ago).
That would be amazing! I had a similar use case and ended up hacking something together using intervals from the Intervals.jl package here. I liked that Intervals.jl has interval types parametrized by each endpoint being unbounded, open or closed.
Another package that could be relevant here is DomainSets.jl.
Allowing products of intervals should go a long way.
There are a couple of general challenges:
At the same time, we obviously want lots of nice capabilities, so we need to try to find a good middle ground.
IntervalsSets
has
help?> IntervalSets.Interval
An Interval{L,R}(left, right) where L,R are :open or :closed is an
interval set containg x such that
1. left ≤ x ≤ right if L == R == :closed
2. left < x ≤ right if L == :open and R == :closed
3. left ≤ x < right if L == :closed and R == :open, or
4. left < x < right if L == R == :open
I also added InfiniteArrays.jl
, mostly (for now) to use its nice definition of ∞
, so for example we can write Poisson ≪ CountingMeasure(ℤ[0:∞])
. I don't see that IntervalSets
has half-lines. 0..∞
returns a value, but I haven't checked any of its properties to make sure it works as we'd expect.
Fully agree! I was previously using Intervals.jl
here for exactly this reason, i.e., letting type information capture half-lines (for example Intervals.Interval{Int64, Closed, Unbounded}
), but 0..∞
actually seems even better (assuming it has the right properties of course). At least the following works (although type information of Intervals.Interval
is less ambiguous, especially regarding which side is unbounded):
julia> halfline = 0..∞
0..∞
julia> typeof(halfline)
Interval{:closed,:closed,Union{InfiniteArrays.Infinity, Int64}}
julia> in(1, halfline)
true
julia> in(-2, halfline)
false
Following up on this as well (it's functionality I would love to have), i.e., to be able to call m(ℐ)
where m::AbstractMeasure
and ℐ::Interval
. At least for probability measures, it would be possible to implement this given access to cdf
and the density with respect to Dirac
at interval end points (depending on whether an interval is open, closed etc). On the other hand this would depend on IntervalSets
which would be an additional dependency. Would there be any scope for reincluding this package in MeasureTheory.jl
?
(Related discussion in https://github.com/cscherrer/MeasureTheory.jl/pull/130)
Thanks @nignatiadis . @oschulz and I were talking about this recently, and I think it's a good idea.
I think a full representation of sigma algebras will always be intractable (but I'd love to be wrong about this). But for a given measure, there's usually a coarse representation for which the measure can be evaluated easily and efficiently. For univariate continuous (Lebesgue-dominated) measures intervals are a good fit.
We could have something with finer granularity (disjoint sets of intervals, or interval trees) but that has a cost of heavier dependencies. But IntervalSets is very light, so that should be good. Happy to take a PR on this :)
But IntervalSets is very light, so that should be good.
I agree, at least for univariate measures IntervalSet
s would be a good solution. And maybe a vector of intervals for powers of univariate measures?
We definitely should add massof
(good name, @cscherrer ?) to MeasureBase as a first step. Do we want massof(measure)
to return the mass of the whole space, or should that be massof(measure, Omega)
or so?
Oh, also - if we support truncation of measures (we should, where applicable), then getting the mass in a subspace could also be expressed as getting the mass of a truncated measure.
Yes, we started some discussion of that here: https://github.com/JuliaMath/DensityInterface.jl/issues/8
I think we should prototype this for addition to MeasureBase. Let's discuss further here: https://github.com/cscherrer/MeasureBase.jl/issues/82
depending on how you wanna use mesures on the reals, it seems to me that something like having measures provide a sorta of "valuation" function on the elements of their sigma algebras might be useful? (or at least the generators of the sigma algebras etc etc, lets ignore filtrations )
eg, for the Real line (and approximations thereof), the sigma algebra generator set would be intervals (open or closed or clopen etc), because we can define the lesbegue/riemann measure on these to be the length ?
would this allow eg, talking about dirac delta as a measure/distribution?