Open sethaxen opened 1 year ago
This also makes it easy to create axial distributions from directional distributions:
plot(wrapped(VonMises(π/4, 10), -π, π, 2); proj=:polar, label="")
In some cases, like WrappedNormal in https://github.com/JuliaStats/Distributions.jl/issues/1715, depending on the parameters of unwrapped, we might at construction time be able to compute some heuristic to decide which method to use e.g. for density evaluation, which the above approach would require us do during every density evaluation. One solution would be to add some field of arbitrary type to Wrapped that could in an overloaded constructor be filled with any relevant precomputations that would be used in pdf, etc.
After more thought, this can also be handled generically. For some arbitrary wrapped distribution, we can compute the density by:
A field use_characteristic::Bool
, defaulting to False
, would specify which approach should be used. One can then overload wrapped(::MyDist, l, u)
to specify that the characteristic function should instead be used, which can in special cases like WrappedNormal
be chosen by the parameters.
1715 proposes adding the Wrapped Normal distribution. Other common named wrapped distributions include:
One could support these generically, as well as arbitrary wrappings, with a "wrapper" distribution
Wrapped
, that could take a distribution with support on the real line and an interval around which to wrap it. e.g.Advantages
truncated
andcensored
WrappedNormal
where we have more efficient ways to evaluate the seriesDisadvantages:
WrappedNormal
in #1715, depending on the parameters ofunwrapped
, we might at construction time be able to compute some heuristic to decide which method to use e.g. for density evaluation, which the above approach would require us do during every density evaluation. One solution would be to add some field of arbitrary type toWrapped
that could in an overloaded constructor be filled with any relevant precomputations that would be used inpdf
, etc.An example usage
adapted from original post by @sethaxen in https://github.com/JuliaStats/Distributions.jl/issues/1715#issuecomment-1536129396