tpapp / TransformVariables.jl

Transformations to contrained variables from ℝⁿ.
Other
66 stars 14 forks source link

simplify interface #8

Closed tpapp closed 6 years ago

tpapp commented 6 years ago

Instead of transform_at getting a vector and an index, a view would be easier to handle for user extensions. Proposed name: transform_with(flag, t, x).

  1. [x] benchmark current state of the package
  2. [x] rewrite interface
  3. [x] compare benchmarks
tpapp commented 6 years ago

Benchmarking before (my laptop, at 93a66ea):

using Statistics
using TransformVariables
using BenchmarkTools

BenchmarkTools.DEFAULT_PARAMETERS.samples = 1000

function time_random(t; N = 50)
    b̄ = mean([(x = randn(dimension(t));
               print(".");
               @belapsed transform_and_logjac($t, $x)) for _ in 1:N])
    println()
    b̄
end

ts = to_tuple(to_ℝ₊, to_𝕀, to_unitvec(5), to_corr_cholesky(4))
julia> time_random(ts)
..................................................
9.972157615325521e-7
tpapp commented 6 years ago

New setup (69d9535):

julia> time_random(ts)
..................................................
1.0685129903332343e-6

Should investigate further later, this is good enough for now.

tpapp commented 6 years ago

Fixed by #10.