text
stringlengths 0
601k
|
---|
let mul ( ) = Alcotest . ( check bool ) " mul " true ( To_test . mul x2 ) |
let dot ( ) = Alcotest . ( check bool ) " dot " true ( To_test . dot ( ) ) |
let add_scalar ( ) = Alcotest . ( check bool ) " add_scalar " true ( To_test . add_scalar ( ) ) |
let mul_scalar ( ) = Alcotest . ( check bool ) " mul_scalar " true ( To_test . mul_scalar ( ) ) |
let min ( ) = Alcotest . ( check bool ) " min " true ( To_test . min ( ) ) |
let max ( ) = Alcotest . ( check bool ) " max " true ( To_test . max ( ) ) |
let map ( ) = Alcotest . ( check bool ) " map " true ( To_test . map ( ) ) |
let fold ( ) = Alcotest . ( check ( float eps ) ) " fold " ( M . sum x2 ) ( To_test . fold x2 ) |
let foldi ( ) = Alcotest . ( check bool ) " foldi " true ( To_test . foldi ( ) ) |
let foldi_nz ( ) = Alcotest . ( check bool ) " foldi_nz " true ( To_test . foldi_nz ( ) ) |
let filter ( ) = Alcotest . ( check bool ) " filter " true ( To_test . filter ( ) ) |
let fold_rows ( ) = Alcotest . ( check bool ) " fold_rows " true ( To_test . fold_rows ( ) ) |
let fold_cols ( ) = Alcotest . ( check bool ) " fold_cols " true ( To_test . fold_cols ( ) ) |
let sum_rows ( ) = Alcotest . ( check bool ) " sum_rows " true ( To_test . sum_rows ( ) ) |
let sum_cols ( ) = Alcotest . ( check bool ) " sum_cols " true ( To_test . sum_cols ( ) ) |
let of_array ( ) = Alcotest . ( check bool ) " of_array " true ( To_test . of_array ( ) ) |
let save_load ( ) = Alcotest . ( check bool ) " save_load " true ( To_test . save_load ( ) ) |
let test_set = [ " sequential " , ` Slow , sequential ; " row_num " , ` Slow , row_num ; " col_num " , ` Slow , col_num ; " numel " , ` Slow , numel ; " transpose " , ` Slow , transpose ; " get " , ` Slow , get ; " set " , ` Slow , set ; " row " , ` Slow , row ; " col " , ` Slow , col ; " fill " , ` Slow , fill ; " trace " , ` Slow , trace ; " sum " , ` Slow , sum ; " exists " , ` Slow , exists ; " not_exists " , ` Slow , not_exists ; " for_all " , ` Slow , for_all ; " equal " , ` Slow , equal ; " not_equal " , ` Slow , not_equal ; " less " , ` Slow , less ; " greater " , ` Slow , greater ; " greater_equal " , ` Slow , greater_equal ; " less_equal " , ` Slow , less_equal ; " is_zero " , ` Slow , is_zero ; " is_positive " , ` Slow , is_positive ; " is_negative " , ` Slow , is_negative ; " is_nonnegative " , ` Slow , is_nonnegative ; " is_nonpositive " , ` Slow , is_nonpositive ; " add " , ` Slow , add ; " mul " , ` Slow , mul ; " dot " , ` Slow , dot ; " add_scalar " , ` Slow , add_scalar ; " mul_scalar " , ` Slow , mul_scalar ; " min " , ` Slow , min ; " max " , ` Slow , max ; " map " , ` Slow , map ; " fold " , ` Slow , fold ; " foldi " , ` Slow , foldi ; " foldi_nz " , ` Slow , foldi_nz ; " filter " , ` Slow , filter ; " fold_rows " , ` Slow , fold_rows ; " fold_cols " , ` Slow , fold_cols ; " sum_rows " , ` Slow , sum_rows ; " sum_cols " , ` Slow , sum_cols ; " of_array " , ` Slow , of_array ; " save_load " , ` Slow , save_load ] |
let ndarray = Alcotest . testable ( fun _p ( _x : ( float , float64_elt ) M . t ) -> ( ) ) M . equal |
let x0 = M . zeros Float64 [ | 2 ; 2 ; 3 ] | |
let _ = M . set x0 [ | 0 ; 0 ; 1 ] | 1 . ; M . set x0 [ | 0 ; 1 ; 0 ] | 2 . ; M . set x0 [ | 1 ; 0 ; 0 ] | 3 . |
let x1 = M . zeros Float64 [ | 2 ; 2 ; 3 ] | |
let _ = M . set x1 [ | 0 ; 0 ; 1 ] | 1 . ; M . set x1 [ | 0 ; 0 ; 2 ] | 2 . ; M . set x1 [ | 0 ; 1 ; 1 ] | 3 . ; M . set x1 [ | 1 ; 0 ; 0 ] | 4 . |
let x2 = M . zeros Float64 [ | 2 ; 2 ; 3 ] | |
let _ = M . set x2 [ | 0 ; 0 ; 1 ] | 2 . ; M . set x2 [ | 0 ; 0 ; 2 ] | 2 . ; M . set x2 [ | 0 ; 1 ; 0 ] | 2 . ; M . set x2 [ | 0 ; 1 ; 1 ] | 3 . ; M . set x2 [ | 1 ; 0 ; 0 ] | 7 . |
module To_test = struct let shape ( ) = M . shape x0 = [ | 2 ; 2 ; 3 ] | let num_dims ( ) = M . num_dims x0 = 3 let nth_dim ( ) = M . nth_dim x0 2 = 3 let numel ( ) = M . numel x0 = 12 let nnz ( ) = M . nnz x0 = 3 let density ( ) = M . density x0 = 3 . . / 12 . let get ( ) = M . get x0 [ | 0 ; 1 ; 0 ] | = 2 . let set ( ) = let x = M . zeros Float64 [ | 2 ; 2 ; 3 ] | in M . set x [ | 1 ; 0 ; 1 ] | 5 . ; M . get x [ | 1 ; 0 ; 1 ] | = 5 . let slice ( ) = let y = M . slice [ | None ; Some 0 ; Some 0 ] | x0 in let z = M . zeros Float64 [ | 2 ] | in M . set z [ | 1 ] | 3 . ; M . equal y z let copy ( ) = M . copy x0 = x0 let map ( ) = M . map ( fun a -> a . + 1 . ) x0 |> M . sum = 18 . let map_nz ( ) = M . map_nz ( fun a -> a . + 1 . ) x0 |> M . sum = 9 . let fold ( ) = M . fold ( fun c a -> c . + a ) 0 . x0 = 6 . let foldi ( ) = let a = M . foldi ( fun i c a -> if i . ( 2 ) = 0 then c . + a else c ) 0 . x0 in a = 5 . let fold_nz ( ) = M . fold ~ axis [ :| None ; None ; Some 0 ] | ( fun c a -> c . + a ) 1 . x0 = 6 . let foldi_nz ( ) = M . fold ~ axis [ :| None ; None ; Some 0 ] | ( fun c a -> if a > 2 . then c . + a else c ) 1 . x0 = 4 . let add ( ) = M . equal ( M . add x0 x1 ) x2 let mul ( ) = M . mul x0 x1 |> M . sum = 13 . let add_scalar ( ) = M . add_scalar x0 2 . |> M . sum = 12 . let mul_scalar ( ) = M . mul_scalar x0 2 . |> M . sum = 12 . let abs ( ) = M . equal ( M . abs x0 ) x0 let neg ( ) = M . equal ( M . map ( fun a -> - 1 . . * a ) x0 ) ( M . neg x0 ) let sum ( ) = M . sum x0 = 6 . let min ( ) = M . min x0 = 0 . let max ( ) = M . max x0 = 3 . let is_zero ( ) = M . is_zero x0 let is_positive ( ) = M . is_positive x0 let is_negative ( ) = M . is_negative x0 let is_nonnegative ( ) = M . is_nonnegative x0 let equal ( ) = M . equal x0 x1 let greater ( ) = M . greater x2 x0 let greater_equal ( ) = M . greater_equal x2 x0 let filter ( ) = M . filter ( ( = ) 3 . ) x0 = [ | [ | 1 ; 0 ; 0 ] | ] | let filteri ( ) = M . filteri ( fun i a -> i . ( 2 ) = 1 && a = 3 . ) x1 = [ | [ | 0 ; 1 ; 1 ] | ] | let filteri_nz ( ) = M . filteri ( fun i a -> i . ( 0 ) = 1 && a = 4 . ) x1 = [ | [ | 1 ; 0 ; 0 ] | ] | let transpose ( ) = let y = M . copy x0 in let y = M . transpose y in M . get y [ | 1 ; 0 ; 0 ] | = 1 . && M . get y [ | 0 ; 1 ; 0 ] | = 2 . && M . get y [ | 0 ; 0 ; 1 ] | = 3 . let flatten ( ) = M . get ( M . flatten x0 ) [ | 3 ] | = 2 . let reshape ( ) = M . get ( M . reshape x0 [ | 2 ; 3 ; 2 ] ) | [ | 0 ; 1 ; 1 ] | = 2 . let of_array ( ) = let a = [ | [ | 0 ; 0 ; 1 ] , | 1 . ; [ | 0 ; 1 ; 0 ] , | 2 . ; [ | 1 ; 0 ; 0 ] , | 3 . ] | in let y = M . of_array Float64 [ | 2 ; 2 ; 3 ] | a in M . equal y x0 let save_load ( ) = M . save x0 " ds_nda . tmp " ; let y = M . load Float64 " ds_nda . tmp " in M . equal x0 y end |
let shape ( ) = Alcotest . ( check bool ) " shape " true ( To_test . shape ( ) ) |
let num_dims ( ) = Alcotest . ( check bool ) " num_dims " true ( To_test . num_dims ( ) ) |
let nth_dim ( ) = Alcotest . ( check bool ) " nth_dim " true ( To_test . nth_dim ( ) ) |
let numel ( ) = Alcotest . ( check bool ) " numel " true ( To_test . numel ( ) ) |
let nnz ( ) = Alcotest . ( check bool ) " nnz " true ( To_test . nnz ( ) ) |
let density ( ) = Alcotest . ( check bool ) " density " true ( To_test . density ( ) ) |
let get ( ) = Alcotest . ( check bool ) " get " true ( To_test . get ( ) ) |
let set ( ) = Alcotest . ( check bool ) " set " true ( To_test . set ( ) ) |
let slice ( ) = Alcotest . ( check bool ) " slice " true ( To_test . slice ( ) ) |
let copy ( ) = Alcotest . ( check bool ) " copy " true ( To_test . copy ( ) ) |
let map ( ) = Alcotest . ( check bool ) " map " true ( To_test . map ( ) ) |
let map_nz ( ) = Alcotest . ( check bool ) " map_nz " true ( To_test . map_nz ( ) ) |
let fold ( ) = Alcotest . ( check bool ) " fold " true ( To_test . fold ( ) ) |
let foldi ( ) = Alcotest . ( check bool ) " foldi " true ( To_test . foldi ( ) ) |
let fold_nz ( ) = Alcotest . ( check bool ) " fold_nz " true ( To_test . fold_nz ( ) ) |
let foldi_nz ( ) = Alcotest . ( check bool ) " foldi_nz " true ( To_test . foldi_nz ( ) ) |
let add ( ) = Alcotest . ( check bool ) " add " true ( To_test . add ( ) ) |
let mul ( ) = Alcotest . ( check bool ) " mul " true ( To_test . mul ( ) ) |
let add_scalar ( ) = Alcotest . ( check bool ) " add_scalar " true ( To_test . add_scalar ( ) ) |
let mul_scalar ( ) = Alcotest . ( check bool ) " mul_scalar " true ( To_test . mul_scalar ( ) ) |
let abs ( ) = Alcotest . ( check bool ) " abs " true ( To_test . abs ( ) ) |
let neg ( ) = Alcotest . ( check bool ) " neg " true ( To_test . neg ( ) ) |
let sum ( ) = Alcotest . ( check bool ) " sum " true ( To_test . sum ( ) ) |
let min ( ) = Alcotest . ( check bool ) " min " true ( To_test . min ( ) ) |
let max ( ) = Alcotest . ( check bool ) " max " true ( To_test . max ( ) ) |
let is_zero ( ) = Alcotest . ( check bool ) " is_zero " false ( To_test . is_zero ( ) ) |
let is_positive ( ) = Alcotest . ( check bool ) " is_positive " false ( To_test . is_positive ( ) ) |
let is_negative ( ) = Alcotest . ( check bool ) " is_negative " false ( To_test . is_negative ( ) ) |
let is_nonnegative ( ) = Alcotest . ( check bool ) " is_nonnegative " true ( To_test . is_nonnegative ( ) ) |
let equal ( ) = Alcotest . ( check bool ) " equal " false ( To_test . equal ( ) ) |
let greater ( ) = Alcotest . ( check bool ) " greater " false ( To_test . greater ( ) ) |
let greater_equal ( ) = Alcotest . ( check bool ) " greater_equal " true ( To_test . greater_equal ( ) ) |
let filter ( ) = Alcotest . ( check bool ) " filter " true ( To_test . filter ( ) ) |
let filteri ( ) = Alcotest . ( check bool ) " filteri " true ( To_test . filteri ( ) ) |
let filteri_nz ( ) = Alcotest . ( check bool ) " filteri_nz " true ( To_test . filteri_nz ( ) ) |
let transpose ( ) = Alcotest . ( check bool ) " transpose " true ( To_test . transpose ( ) ) |
let flatten ( ) = Alcotest . ( check bool ) " flatten " true ( To_test . flatten ( ) ) |
let reshape ( ) = Alcotest . ( check bool ) " reshape " true ( To_test . reshape ( ) ) |
let of_array ( ) = Alcotest . ( check bool ) " of_array " true ( To_test . of_array ( ) ) |
let save_load ( ) = Alcotest . ( check bool ) " save_load " true ( To_test . save_load ( ) ) |
let test_set = [ " shape " , ` Slow , shape ; " num_dims " , ` Slow , num_dims ; " nth_dim " , ` Slow , nth_dim ; " numel " , ` Slow , numel ; " nnz " , ` Slow , nnz ; " density " , ` Slow , density ; " get " , ` Slow , get ; " set " , ` Slow , set ; " slice " , ` Slow , slice ; " copy " , ` Slow , copy ; " map " , ` Slow , map ; " map_nz " , ` Slow , map_nz ; " fold " , ` Slow , fold ; " foldi " , ` Slow , foldi ; " fold_nz " , ` Slow , fold_nz ; " foldi_nz " , ` Slow , foldi_nz ; " add " , ` Slow , add ; " mul " , ` Slow , mul ; " add_scalar " , ` Slow , add_scalar ; " mul_scalar " , ` Slow , mul_scalar ; " abs " , ` Slow , abs ; " neg " , ` Slow , neg ; " sum " , ` Slow , sum ; " min " , ` Slow , min ; " max " , ` Slow , max ; " is_zero " , ` Slow , is_zero ; " is_positive " , ` Slow , is_positive ; " is_negative " , ` Slow , is_negative ; " is_nonnegative " , ` Slow , is_nonnegative ; " equal " , ` Slow , equal ; " greater " , ` Slow , greater ; " greater_equal " , ` Slow , greater_equal ; " filter " , ` Slow , filter ; " filteri " , ` Slow , filteri ; " filteri_nz " , ` Slow , filteri_nz ; " transpose " , ` Slow , transpose ; " flatten " , ` Slow , flatten ; " reshape " , ` Slow , reshape ; " of_array " , ` Slow , of_array ; " save_load " , ` Slow , save_load ] |
module To_test = struct let mannwhitneyu_both_side x y = let h = M . mannwhitneyu x y in h . p_value let mannwhitneyu_right_side x y = let h = M . mannwhitneyu ~ side : M . RightSide x y in h . p_value let mannwhitneyu_left_side x y = let h = M . mannwhitneyu ~ side : M . LeftSide x y in h . p_value let wilcoxon_both_side x y = let h = M . wilcoxon x y in h . p_value let wilcoxon_right_side x y = let h = M . wilcoxon ~ side : M . RightSide x y in h . p_value let wilcoxon_left_side x y = let h = M . wilcoxon ~ side : M . LeftSide x y in h . p_value let fisher_test_both_side a b c d = let h = M . fisher_test a b c d in h . p_value let fisher_test_right_side a b c d = let h = M . fisher_test ~ side : M . RightSide a b c d in h . p_value let fisher_test_left_side a b c d = let h = M . fisher_test ~ side : M . LeftSide a b c d in h . p_value let ks_test_pval a b = let h = M . ks_test a b in h . p_value let ks_test_statistic a b = let h = M . ks_test a b in h . score let ks2_test_pval a b = let h = M . ks2_test a b in h . p_value let ks2_test_statistic a b = let h = M . ks2_test a b in h . score let hist_uni n x = let h = M . histogram ( ` N n ) x in h . counts let hist_uni_sorted n x = let h = M . histogram_sorted ( ` N n ) x in h . counts let hist_bin bins x = let h = M . histogram ( ` Bins bins ) x in h . counts let hist_bin_sorted bins x = let h = M . histogram_sorted ( ` Bins bins ) x in h . counts let hist_bin_weighted bins weights x = let h = M . histogram ( ` Bins bins ) ~ weights x in h . counts , h . weighted_counts let hist_bin_weighted_sorted bins weights x = let h = M . histogram_sorted ( ` Bins bins ) ~ weights x in h . counts , h . weighted_counts let hist_normalise bins ? weights x = let h = M . histogram ( ` Bins bins ) ? weights x |> M . normalise |> M . normalise_density in h . normalised_counts , h . density let tukey_fences x = M . tukey_fences x let quantiles ~ p x = let f = M . quantile x in Some ( Array . map f p ) end |
module Data = struct let x1 = [ | 0 . ; - 1 . ; 0 . ; sqrt 0 . 5 ; 2 . ] | let x1_sorted = [ | - 1 . ; 0 . ; 0 . ; sqrt 0 . 5 ; 2 . ] | let w1 = [ | 0 . ; 2 . ; 1 . ; 1 . ; 0 . 2 ] | let w1_sorted = [ | 2 . ; 0 . ; 1 . ; 1 . ; 0 . 2 ] | let bin1 = [ | - 1 . ; 0 . ] | let bin_wrong = [ | 4 . ] | let bin_low = [ | - 3 . ; - 2 . ] | let bin_high = [ | 3 . ; 4 . ] | let x2 = Array . append x1 [ | infinity ] | let x2_sorted = Array . append x1_sorted [ | infinity ] | let w2 = Array . append w1 [ | 0 . 2 ] | let bin2 = [ | - 1 . ; 0 . ; sqrt 0 . 5 ; 3 . ] | let bin2_inf = [ | . - infinity ; 0 . ; sqrt 0 . 5 ; infinity ] | let with_outliers = [ | - 10000 . 0 ; 0 . 0 ; 1 . 0 ; 2 . 0 ; 10000 . 0 ] | end |
let mannwhitneyu_test_both_side_asym ( ) = Alcotest . ( check bool ) " mannwhitneyu_test_both_side_asym " true ( abs_float ( To_test . mannwhitneyu_both_side [ | 4 . ; 5 . ; 6 . ; 7 . ; 7 . ; 7 . ] | [ | 1 . ; 2 . ; 3 . ; 3 . ] ) | . - 0 . 0093747684594348759 < eps ) |
let mannwhitneyu_test_right_side_asym ( ) = Alcotest . ( check bool ) " mannwhitneyu_test_right_side_asym " true ( abs_float ( To_test . mannwhitneyu_right_side [ | 4 . ; 5 . ; 6 . ; 7 . ; 7 . ; 7 . ] | [ | 1 . ; 2 . ; 3 . ; 3 . ] ) | . - 0 . 0046873842297174379 < eps ) |
let mannwhitneyu_test_left_side_asym ( ) = Alcotest . ( check bool ) " mannwhitneyu_test_left_side_asym " true ( abs_float ( To_test . mannwhitneyu_left_side [ | 4 . ; 5 . ; 6 . ; 7 . ; 7 . ; 7 . ] | [ | 1 . ; 2 . ; 3 . ; 3 . ] ) | . - 0 . 99531261577028252 < eps ) |
let mannwhitneyu_test_both_side_exact ( ) = Alcotest . ( check bool ) " mannwhitneyu_test_both_side_asym " true ( abs_float ( To_test . mannwhitneyu_both_side [ | 5 . ; 6 . ; 7 . ; 4 . ; 25 . ; 12 . ; 14 . ] | [ | 1 . ; 2 . ; 3 . ; 103 . ] ) | . - 0 . 2303 < 0 . 001 ) |
let mannwhitneyu_test_right_side_exact ( ) = Alcotest . ( check bool ) " mannwhitneyu_test_right_side_asym " true ( abs_float ( To_test . mannwhitneyu_right_side [ | 5 . ; 6 . ; 7 . ; 4 . ; 25 . ; 12 . ; 14 . ] | [ | 1 . ; 2 . ; 3 . ; 103 . ] ) | . - 0 . 1152 < 0 . 001 ) |
let mannwhitneyu_test_left_side_exact ( ) = Alcotest . ( check bool ) " mannwhitneyu_test_left_side_asym " true ( abs_float ( To_test . mannwhitneyu_left_side [ | 5 . ; 6 . ; 7 . ; 4 . ; 25 . ; 12 . ; 14 . ] | [ | 1 . ; 2 . ; 3 . ; 103 . ] ) | . - 0 . 9182 < 0 . 001 ) |
let fisher_test_both_side ( ) = Alcotest . ( check bool ) " fisher_test_both_side " true ( abs_float ( To_test . fisher_test_both_side 45 25 10 15 . - 0 . 057776279489461277 ) < eps ) |
let fisher_test_right_side ( ) = Alcotest . ( check bool ) " fisher_test_right_side " true ( abs_float ( To_test . fisher_test_right_side 45 25 10 15 . - 0 . 0307852082455 ) < eps ) |
let fisher_test_left_side ( ) = Alcotest . ( check bool ) " fisher_test_left_side " true ( abs_float ( To_test . fisher_test_left_side 45 25 10 15 . - 0 . 990376800656 ) < eps ) |
let wilcoxon_test_both_side_exact ( ) = Alcotest . ( check bool ) " wilcoxon_test_both_side_exact " true ( abs_float ( To_test . wilcoxon_both_side [ | 1 . ; 2 . ; 3 . ; 4 . ; 5 . ] | [ | 10 . ; 9 . ; 8 . ; 7 . ; 6 . ] | . - 0 . 0625 ) < 0 . 001 ) |
let wilcoxon_test_right_side_exact ( ) = Alcotest . ( check bool ) " wilcoxon_test_right_side_exact " true ( abs_float ( To_test . wilcoxon_right_side [ | 1 . ; 2 . ; 3 . ; 4 . ; 5 . ] | [ | 10 . ; 9 . ; 8 . ; 7 . ; 6 . ] | . - 1 . ) < 0 . 001 ) |
let wilcoxon_test_left_side_exact ( ) = Alcotest . ( check bool ) " wilcoxon_test_left_side_exact " true ( abs_float ( To_test . wilcoxon_left_side [ | 1 . ; 2 . ; 3 . ; 4 . ; 5 . ] | [ | 10 . ; 9 . ; 8 . ; 7 . ; 6 . ] | . - 0 . 03125 ) < 0 . 001 ) |
let wilcoxon_test_both_side_asymp ( ) = Alcotest . ( check bool ) " wilcoxon_test_both_side_asymp " true ( abs_float ( To_test . wilcoxon_both_side [ | 10 . ; 9 . ; 8 . ; 7 . ; 6 . ] | [ | 10 . ; 3 . ; 1 . ; 3 . ; 2 . ] | . - 0 . 0656 ) < 0 . 001 ) |
let wilcoxon_test_right_side_asymp ( ) = Alcotest . ( check bool ) " wilcoxon_test_right_side_asymp " true ( abs_float ( To_test . wilcoxon_right_side [ | 10 . ; 9 . ; 8 . ; 7 . ; 6 . ] | [ | 10 . ; 3 . ; 1 . ; 3 . ; 2 . ] | . - 0 . 9672 ) < 0 . 001 ) |
let wilcoxon_test_left_side_asymp ( ) = Alcotest . ( check bool ) " wilcoxon_test_left_side_asymp " true ( abs_float ( To_test . wilcoxon_left_side [ | 10 . ; 9 . ; 8 . ; 7 . ; 6 . ] | [ | 10 . ; 3 . ; 1 . ; 3 . ; 2 . ] | . - 0 . 0328 ) < 0 . 001 ) |
let ks_teststat1 ( ) = Alcotest . ( check bool ) " ks_test test stat " true ( abs_float ( To_test . ks_test_statistic [ | 1 . ; 2 . ; 3 . ] | ( fun x -> M . gaussian_cdf ~ mu : 0 . ~ sigma : 1 . x ) . - 0 . 8413 ) < 0 . 0001 ) |
let ks_teststat2 ( ) = Alcotest . ( check bool ) " ks_test pval 4 " true ( abs_float ( To_test . ks_test_statistic [ | 0 . ; 0 . ; 0 . ] | ( fun x -> M . gaussian_cdf ~ mu : 0 . ~ sigma : 1 . x ) . - 0 . 5 ) < 0 . 0001 ) |
let ks_pval_test1 ( ) = Alcotest . ( check bool ) " ks_test pval 1 " true ( abs_float ( To_test . ks_test_pval [ | 1 . ; 2 . ; 3 . ] | ( fun x -> M . gaussian_cdf ~ mu : 0 . ~ sigma : 1 . x ) . - 0 . 0079 ) < 0 . 0001 ) |
let ks_pval_test2 ( ) = Alcotest . ( check bool ) " ks_test pval 2 " true ( abs_float ( To_test . ks_test_pval [ | 0 . ; 0 . 25 ; 0 . 15 ; 0 . 05 ] | ( fun x -> M . gaussian_cdf ~ mu : 0 . ~ sigma : 1 . x ) . - 0 . 1875 ) < 0 . 0001 ) |
let ks_pval_test3 ( ) = Alcotest . ( check bool ) " ks_test pval 3 " true ( abs_float ( To_test . ks_test_pval ( Array . mapi ( fun i _ -> 0 . 99 . / 2000 . . * float_of_int i ) ( Array . create_float 2000 ) ) ( fun x -> M . uniform_cdf ~ a : 0 . ~ b : 1 . x ) . - 0 . 98025 ) < 0 . 00001 ) |
let ks_pval_test4 ( ) = Alcotest . ( check bool ) " ks_test pval 4 " true ( abs_float ( To_test . ks_test_pval ( Array . mapi ( fun i _ -> 0 . 99 . / 10_000 . . * float_of_int i ) ( Array . create_float 10_000 ) ) ( fun x -> M . uniform_cdf ~ a : 0 . ~ b : 1 . x ) . - 0 . 25953 ) < 0 . 00001 ) |
let ks_pval_test5 ( ) = Alcotest . check_raises " ks_test exception " Owl_exception . EMPTY_ARRAY ( fun _ -> ignore ( To_test . ks_test_pval [ ] || ( fun x -> M . gaussian_cdf ~ mu : 0 . ~ sigma : 1 . x ) ) ) |
let ks2_teststat ( ) = Alcotest . ( check bool ) " ks2_test test statistic " true ( abs_float ( To_test . ks2_test_statistic [ | 0 . ; 2 . ; 3 . ; 1 . ; 4 . ] | [ | 6 . ; 5 . ; 3 . ; 4 . ] | . - 0 . 6 ) < 0 . 0001 ) |
let ks2_pval_test1 ( ) = Alcotest . ( check bool ) " ks2_test p value " true ( abs_float ( To_test . ks2_test_pval [ | 0 . ; 2 . ; 3 . ; 1 . ; 4 . ] | [ | 6 . ; 5 . ; 3 . ; 4 . ] | . - 0 . 2587 ) < 0 . 0001 ) |
let ks2_pval_test2 ( ) = Alcotest . ( check bool ) " ks2_test p value " true ( abs_float ( To_test . ks2_test_pval [ | 8 . 3653642 ; 9 . 39604144 ; 9 . 567219 ; 8 . 95912556 ; 9 . 97116074 ] | [ | 1 . 7835817 ; - 0 . 37877421 ; - 1 . 21761325 ; 0 . 91270459 ; - 1 . 06491371 ] | . - 0 . 003781 ) < 0 . 0001 ) |
let ks2_pval_test3 ( ) = Alcotest . check_raises " ks2_test exception " Owl_exception . EMPTY_ARRAY ( fun _ -> ignore ( To_test . ks2_test_pval [ ] || [ | 1 . ; 2 . ; 3 . ] ) ) | |
let hist_uni_1 ( ) = Alcotest . ( check ( array int ) ) " uniform histogram " [ | 1 ; 3 ; 1 ] | ( To_test . hist_uni 3 Data . x1 ) |
let hist_uni_sorted_1 ( ) = Alcotest . ( check ( array int ) ) " uniform histogram sorted " [ | 1 ; 3 ; 1 ] | ( To_test . hist_uni_sorted 3 Data . x1_sorted ) |
let hist_bins_1 ( ) = Alcotest . ( check ( array int ) ) " histogram with bins " [ | 3 ] | ( To_test . hist_bin Data . bin1 Data . x1 ) |
let hist_bins_low ( ) = Alcotest . ( check ( array int ) ) " bin below " [ | 0 ] | ( To_test . hist_bin Data . bin_low Data . x1 ) |
let hist_bins_high ( ) = Alcotest . ( check ( array int ) ) " bin above " [ | 0 ] | ( To_test . hist_bin Data . bin_high Data . x1 ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.