JuliaApproximation / DomainSets.jl

A Julia package for describing domains as continuous sets of elements
MIT License
72 stars 12 forks source link

Examples? #32

Closed cscherrer closed 5 years ago

cscherrer commented 5 years ago

Hi, this package seems like it could be really useful for Bayesian modeling, specifically the kind of transformations Stan implements. It would be really helpful to have some simple examples as a jumping-off point. I'd like to try to implement things like logistic and log transforms, but I need to get my head around the code first. Anything you can point me to?

dlfivefifty commented 5 years ago

Hi @cscherrer, I had a brief look at Stan but not sure I see the connection. The main point of this package is to provide types that implement in, such as UnitDisk (norm(x) ≤ 1).

There are also maps between domains, maybe this is what you are interested in?

cscherrer commented 5 years ago

Yes, there are a few needs:

Is this not a good use case for your package? I had looked into using TransformVariables.jl which seems great, but may not have as much flexibility of representing different spaces as your approach.

dlfivefifty commented 5 years ago

I think this is a good use case for representing the domains. @daanhb might have comments about support for Jacobians.

daanhb commented 5 years ago

In principle, the stance of the package is that the Jacobian of a map is itself a map.

The minimal amount of information about a map is which types it maps between (these are the type parameters S and T) and an implementation of applymap: this should take an argument x of type S and return something of type T. It is not assumed that maps are invertible, and there is support for specifying left and right inverses. (This flexibility helps to decide membership of a domain in case the dimensions of the spaces of a map differ.)

It is a pretty flexible framework. However, it hasn't been used much yet, and so there aren't many examples I'm afraid.

There is an example of a map in circle.jl. The AngleMap and UnitCircleMap describe the map from the interval to a circle and back. These do not (yet) have jacobians implemented.

An example of a Jacobian is in affine_maps.jl: the jacobian of any linear map is a constant map, see line 14. The affine maps are currently the most used and most developed ones. Compared to some other implementations in other Julia packages, it is not assumed that the matrix is square (i.e. it is not assumed that the map is uniquely invertible).

cscherrer commented 5 years ago

That should give me a good start. Thank you!