-
Notifications
You must be signed in to change notification settings - Fork 55
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
Distributions on manifolds #708
Comments
HI, I think, either the mentioned started package or a new approach with https://github.com/JuliaStats/Distributions.jl, that is combining it with I personally am an optimiser, so the main thing I needed is “some random” starting point. That is what the |
This is a very interesting and nontrivial topic, and I'm happy to say that we have more or less all basic building blocks to answer such questions. It's mostly a matter of developing applications. There are many ways to define distributions on a sphere. Probably the most famous example is the von Mises-Fisher distribution. I haven't added it to Manifolds.jl yet (because it's already in other packages) but we have something better: a generic way of converting Euclidean distributions into manifold distributions. See here: https://juliamanifolds.github.io/Manifolds.jl/latest/tutorials/integration.html . Note that Manifolds.jl tries to work in a coordinate-free way, so it focuses on your second question. Libraries like Bijectors.jl seem to have a good enough interface for working in coordinates so I didn't try to compete there but we could develop it further here if it's needed. I think the main issue with going forward is answering the question of what we want to do with such distributions. Just sampling and computing (log)pdfs? Do we need to compute moments? Do we need parameter estimation? Do we need it to work with some PPLs? |
Thanks for those perspectives, glad there are others thinking about this in Julia :) My usecases only involve random number generation and pdf evaluation (mostly, for MCMC sampling). It's just nontrivial to define a concrete programming object "uniform distribution on the unit sphere".
Potential API could look like this, I guess: d = Uniform(Sphere())
rand(d, Cartesian) # return 3d vector
rand(d, LonLat) # return 2d vector of [lon, lat]
pdf(d, [1, 0, 0]) # error, not clear which measure to use
d_vol = assume_measure(d, VolumeMeasure)
pdf(d_vol, [1, 0, 0]) == Inf # refer to a point by 3d vector
pdf(d_vol, [0, 0]) == Inf # refer to a point by 2d vector of [lon, lat]
d_area = assume_measure(d, AreaMeasure)
pdf(d_area, [1, 0, 0]) == 1/4pi
pdf(d_area, [0, 0]) == 1/4pi
d_ll = assume_measure(d, LonLatMeasure)
pdf(d_ll, [1, 0, 0]) == cos(0)/4pi
pdf(d_ll, [0, 0]) == cos(0)/4pi What do you think, does it look reasonable? |
d = Uniform(Sphere())
rand(d, Cartesian) # return 3d vector
rand(d, LonLat) # return 2d vector of [lon, lat]
pdf(d_vol, [1, 0, 0]) == Inf # refer to a point by 3d vector
pdf(d_vol, [0, 0]) == Inf # refer to a point by 2d vector of [lon, lat] Going by my experience, I'd either wrap the second argument of BTW, I don't really see what would the volume measure be useful for? |
Yeah probably not really useful. My point there was that we shouldn't have
Totally, makes sense! So, pdf(d_area, [1, 0, 0]) == 1/4pi
pdf(d_area, LonLat(0, 0)) == 1/4pi # generic types like LonLat, PolAz, ...
pdf(d_area, SkyCoords.GalCoords(0, 0)) == 1/4pi # can work with existing spherical coordinate types from astronomy and geo packages right?
Indeed, it can easily be a keyword argument. Plays nicely with the pdf definition above as well! rand(d_area)::SVector{3}
rand(d_area, T=LonLat)::LonLat
rand(d_area, T=SkyCoords.GalCoords)::SkyCoords.GalCoords Is that similar to what you are talking about? |
I think I'd prefer to have that
Yes, that makes sense.
Sure, that also looks right. By "going through the sampler" I mean that We can have a small new package for this in JuliaManifolds if you are interested in developing it. I can help but I won't have much time to work on it. |
Indeed, that's another possible approach. Basically,
I may draft something in the near future, with implementations of a few distributions on the sphere. I'm actually only interested in spherical ones for now, but interface would be extensible. |
I may draft something in the near future, with implementations of a few distributions on the sphere. I'm actually only interested in spherical ones for now, but interface would be extensible. Cool!
Definitely
ManifoldMeasures is also worth a look because it already has a few spherical distributions defined. It uses a more generic terminology from measure theory but if you look at the implementation, |
I'm looking for a way to describe distributions on manifolds (for now, spheres), so that their
pdf
is defined in a consistent way. This repo seems to be the natural place to ask such a question. Maybe, Manifolds.jl already contains something relevant?Let's take the simplest example, a uniform distribution on the unit sphere in 3d. What is its
pdf
?pdf
is zero or infinity.pdf = 1/4pi
.pdf = cos(lat)/4pi
.What are consistent ways to handle all these variants?
The text was updated successfully, but these errors were encountered: