Skip to content

Instantly share code, notes, and snippets.

@johnmyleswhite
Created May 12, 2018 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnmyleswhite/685b19f63a3b42a0deffe2029a492e19 to your computer and use it in GitHub Desktop.
Save johnmyleswhite/685b19f63a3b42a0deffe2029a492e19 to your computer and use it in GitHub Desktop.
using Distributions
using HypothesisTests
n_sims = 1_000_000
n = 2
x = Array{Float64}(n)
y = Array{Float64}(n)
p_d = Array{Float64}(n_sims)
for s in 1:n_sims
for i in 1:n
x[i] = rand(Laplace(0.0, 1.0))
y[i] = rand(Laplace(0.0, 1.0))
end
try
p_d[s] = pvalue(UnequalVarianceTTest(x, y))
catch
p_d[s] = NaN
end
end
mean(isfinite.(p_d))
mean(p_d .< 0.05)
mean(p_d .< 0.01)
mean(p_d .< 0.001)
@johnmyleswhite
Copy link
Author

julia> mean(isfinite.(p_d))
1.0

julia> mean(p_d .< 0.05)
0.018487

julia> mean(p_d .< 0.01)
0.002538

julia> mean(p_d .< 0.001)
0.00019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment