Skip to content

Commit

Permalink
Change nr of samples belapsed and # dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterwln committed Oct 22, 2024
1 parent 809dc67 commit 24108bb
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end
for s in 1:6
μ = randn(rng, s)
γ = rand(rng)

@testset let d = MvNormalMeanScalePrecision(μ, γ)
ef = test_exponentialfamily_interface(d;)
end
Expand All @@ -45,10 +45,10 @@ end

d = MvNormalMeanScalePrecision(μ, γ)
ef = convert(ExponentialFamilyDistribution, d)

d1d = NormalMeanPrecision(μ[1], γ)
ef1d = convert(ExponentialFamilyDistribution, d1d)

@test logpartition(ef) logpartition(ef1d)
@test gradlogpartition(ef) gradlogpartition(ef1d)
@test fisherinformation(ef) fisherinformation(ef1d)
Expand Down Expand Up @@ -186,7 +186,7 @@ end
using JET

rng = StableRNG(42)
for k in 10:40
for k in 10:5:40
μ = randn(rng, k)
γ = rand(rng)
cov = γ * I(k)
Expand All @@ -200,27 +200,27 @@ end
@test_opt fisherinformation(ef_small)
@test_opt fisherinformation(ef_full)

fi_mvsp_time = min((@benchmark fisherinformation($ef_small)).times...)
fi_mvsp_time = @elapsed fisherinformation(ef_small)
fi_mvsp_alloc = @allocated fisherinformation(ef_small)

fi_full_time = min((@benchmark fisherinformation($ef_full)).times...)
fi_full_time = @elapsed fisherinformation(ef_full)
fi_full_alloc = @allocated fisherinformation(ef_full)

@test_opt cholinv(fi_small)
@test_opt cholinv(fi_full)

cholinv_time_small = @elapsed cholinv(fi_small)
cholinv_time_small = @belapsed cholinv($fi_small) samples = 3
cholinv_alloc_small = @allocated cholinv(fi_small)

cholinv_time_full = @elapsed cholinv(fi_full)
cholinv_time_full = @belapsed cholinv($fi_full) samples = 3
cholinv_alloc_full = @allocated cholinv(fi_full)

# small time is supposed to be O(k) and full time is supposed to O(k^2)
# the constant C is selected to account to fluctuations in test runs
C = 0.7
@test fi_mvsp_time < fi_full_time/(C*k)
@test fi_mvsp_alloc < fi_full_alloc/(C*k)
@test cholinv_time_small < cholinv_time_full/(C*k)
@test cholinv_alloc_small < cholinv_alloc_full/(C*k)
@test fi_mvsp_time < fi_full_time / (C * k)
@test fi_mvsp_alloc < fi_full_alloc / (C * k)
@test cholinv_time_small < cholinv_time_full / (C * k)
@test cholinv_alloc_small < cholinv_alloc_full / (C * k)
end
end

0 comments on commit 24108bb

Please sign in to comment.