Created
May 11, 2018 20:38
-
-
Save johnmyleswhite/6d1739496c46d02fa2c0f407c63a6d35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Distributions | |
using HypothesisTests | |
n_sims = 1_000_000 | |
n = 20 | |
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 | |
z = rand(Bernoulli(0.5)) | |
x[i] = z * (1e-12 * rand(Bernoulli(0.5))) + (1 - z) * rand(Bernoulli(1e-6)) | |
y[i] = z * (1e-12 * rand(Bernoulli(0.5))) + (1 - z) * rand(Bernoulli(1e-6)) | |
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) |
Author
johnmyleswhite
commented
May 11, 2018
Bug here where z
is re-used.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment