-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* squash * type params simpler * Fix change_metric, change_representer and project for ProbabilitySimplex (#627) * Add Exports, Improve GHA Caches. (#626) * Add a few exports, mainly reexports from ManifoldsBase. * Improve caching. i.e. doing it correctly. * 📖🩹 at least a bit, * 📖🩹 2 * export FisherRaoMetric. * new change metric * add exp and test * Update test/manifolds/probability_simplex.jl * Update src/manifolds/ProbabilitySimplexEuclideanMetric.jl * Update src/manifolds/ProbabilitySimplex.jl Co-authored-by: Seth Axen <seth@sethaxen.com> --------- Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com> Co-authored-by: Ronny Bergmann <git@ronnybergmann.net> Co-authored-by: Seth Axen <seth@sethaxen.com>
- Loading branch information
1 parent
dae9e52
commit d24f6d2
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
exp!(::MetricManifold{ℝ,<:ProbabilitySimplex,<:EuclideanMetric}, q, p, X) = (q .= p .+ X) | ||
function exp!( | ||
::MetricManifold{ℝ,<:ProbabilitySimplex,<:EuclideanMetric}, | ||
q, | ||
p, | ||
X, | ||
t::Number, | ||
) | ||
return (q .= p .+ t .* X) | ||
end | ||
|
||
@doc raw""" | ||
rand(::MetricManifold{ℝ,<:ProbabilitySimplex,<:EuclideanMetric}; vector_at=nothing, σ::Real=1.0) | ||
When `vector_at` is `nothing`, return a random (uniform) point `x` on the [`ProbabilitySimplex`](@ref) with the Euclidean metric | ||
manifold `M` by normalizing independent exponential draws to unit sum, see [^Devroye1986], Theorems 2.1 and 2.2 on p. 207 and 208, respectively. | ||
When `vector_at` is not `nothing`, return a (Gaussian) random vector from the tangent space | ||
``T_{p}\mathrm{\Delta}^n``by shifting a multivariate Gaussian with standard deviation `σ` | ||
to have a zero component sum. | ||
[^Devroye1986]: | ||
> Devroye, L.: | ||
> _Non-Uniform Random Variate Generation_. | ||
> Springer New York, NY, 1986. | ||
> doi: [10.1007/978-1-4613-8643-8](https://doi.org/10.1007/978-1-4613-8643-8) | ||
""" | ||
rand(::MetricManifold{ℝ,<:ProbabilitySimplex,<:EuclideanMetric}; σ::Real=1.0) | ||
|
||
function Random.rand!( | ||
rng::AbstractRNG, | ||
M::MetricManifold{ℝ,<:ProbabilitySimplex,<:EuclideanMetric}, | ||
pX; | ||
vector_at=nothing, | ||
σ=one(eltype(pX)), | ||
) | ||
if isnothing(vector_at) | ||
Random.randexp!(rng, pX) | ||
LinearAlgebra.normalize!(pX, 1) | ||
else | ||
Random.randn!(rng, pX) | ||
pX .= (pX .- mean(pX)) .* σ | ||
end | ||
return pX | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d24f6d2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
d24f6d2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/86223
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: