diff --git a/Project.toml b/Project.toml index e36f8e5..6d9b061 100644 --- a/Project.toml +++ b/Project.toml @@ -9,10 +9,12 @@ ThickNumbers = "b57aa878-5b76-4266-befc-f8e007760995" [compat] SpecialFunctions = "2" +ThickNumbers = "1" julia = "1" [extras] +HypothesisTests = "09f84164-cd44-5f33-b23f-e6b0d136a0d5" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["HypothesisTests", "Test"] diff --git a/test/runtests.jl b/test/runtests.jl index 55ba4a1..089f354 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,17 @@ using GaussianRandomVariables using ThickNumbers +using HypothesisTests using Test +function testscalar(f, μ, σ; n=1000, pval = 0.001) + x = μ .+ σ .* randn(n) + y = f.(x) + g = GVar(μ, σ) + fg = f(g) + z = mid(fg) .+ rad(fg) .* randn(n) + return pvalue(EqualVarianceTTest(y, z)) > pval && pvalue(LeveneTest(y, z)) > pval +end + @testset "GaussianRandomVariables.jl" begin x = 3 ± 1 e = GVar(0, -1) # empty @@ -19,4 +29,12 @@ using Test @test rad(1/x)^2 ≈ rad(x)^2 / mid(x)^4 + 2 * rad(x)^4 / mid(x)^6 @test sqrt(x) ⩪ exp(0.5 * log(x)) rtol=1e-3 @test sqrt(x) ⩪ x^0.5 + + for μ in (2, 3, 10), σ in (0.25,) + @test testscalar(x -> x^2, μ, σ) + @test testscalar(x -> x^1.8, μ, σ) + @test testscalar(exp, μ, σ) + @test testscalar(log, μ, σ) + @test testscalar(sqrt, μ, σ) + end end