Skip to content

Commit 769803d

Browse files
committed
more docs
1 parent 593b6b5 commit 769803d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/src/affine.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,29 @@ This allows a more efficient log-density,
7373
logdensity(d::Normal{(:μ,:ω)}, x) = logdensity(d.ω * (x - d.μ)) + logdet(d.ω)
7474
```
7575

76+
## `AffineTransform`
77+
78+
Transforms like ``z → σ z + μ`` and ``z → ω \ z + μ`` can be represented using an `AffineTransform`. For example,
79+
80+
```julia
81+
julia> f = AffineTransform((μ=3.=2.))
82+
AffineTransform{(:μ, :σ), Tuple{Float64, Float64}}((μ = 3.0, σ = 2.0))
83+
84+
julia> f(1.0)
85+
5.0
86+
```
87+
88+
In the scalar case this is relatively simple to invert. But if `σ` is a matrix, this would require matrix inversion. Adding to this complication is that lower triangular matrices are not closed under matrix inversion.
89+
90+
Our multiple parameterizations make it convenient to deal with these issues. The inverse transform of a ``(μ,σ)`` transform will be in terms of ``(μ,ω)``, and vice-versa. So
91+
92+
```julia
93+
julia> f⁻¹ = inv(f)
94+
AffineTransform{(:μ, :ω), Tuple{Float64, Float64}}((μ = -1.5, ω = 2.0))
95+
96+
julia> f(f⁻¹(4))
97+
4.0
98+
99+
julia> f⁻¹(f(4))
100+
4.0
101+
```

0 commit comments

Comments
 (0)