Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
18 changes: 18 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Loading