Commit a90765e5 authored by Philippe Veber's avatar Philippe Veber
Browse files

tk/Multinomial_test.uniformity_test: opt to reject sites with single AA

parent 33746acc
......@@ -167,12 +167,17 @@ let counts n p =
let h0_sample ~n1 ~n2 p =
counts n1 p, counts n2 p
let uniformity_test ?(alpha = 10.) ~k ~n1 ~n2 test =
let uniformity_test ?(alpha = 10.) ?(filter_out_single_category = false) ~k ~n1 ~n2 test =
let p_values =
Array.init 10_000 ~f:(fun _ ->
let p = random_discrete_probability k ~alpha in
let x1, x2 = h0_sample ~n1 ~n2 p in
(test { k ; x1 ; x2 }).pvalue
let rec loop () =
let p = random_discrete_probability k ~alpha in
let x1, x2 = h0_sample ~n1 ~n2 p in
let d = { k ; x1 ; x2 } in
if filter_out_single_category && data_nz d < 2 then loop ()
else (test d).pvalue
in
loop ()
)
in
ignore (OCamlR_graphics.hist ~breaks:(`n 20) p_values : OCamlR_graphics.hist)
......
......@@ -35,6 +35,7 @@ end
val uniformity_test :
?alpha:float ->
?filter_out_single_category:bool ->
k:int ->
n1:int ->
n2:int ->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment