text stringlengths 12 786k |
|---|
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... |
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 . ... |
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 . ... |
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 . ] ) | . - ... |
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 . ] ) | . ... |
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 . ] ) | . - ... |
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 . ]... |
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 . ... |
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 . ]... |
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 ... |
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 . ) ... |
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 ... |
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 ... |
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 . 96... |
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 ... |
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... |
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 ... |
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 ;... |
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 ) |
let hist_bins_sorted_low ( ) = Alcotest . ( check ( array int ) ) " bin below sorted " [ | 0 ] | ( To_test . hist_bin_sorted Data . bin_low Data . x1_sorted ) |
let hist_bins_sorted_high ( ) = Alcotest . ( check ( array int ) ) " bin above sorted " [ | 0 ] | ( To_test . hist_bin Data . bin_high Data . x1_sorted ) |
let hist_bins_wrong ( ) = Alcotest . ( check_raises ) " histogram with bins " ( Failure " Need at least two bin boundaries " ) ! ( fun ( ) -> To_test . hist_bin Data . bin_wrong Data . x1 |> ignore ) |
let hist_bins_2 ( ) = Alcotest . ( check ( array int ) ) " histogram with infinite bins " [ | 1 ; 2 ; 2 ] | ( To_test . hist_bin Data . bin2 Data . x2 ) |
let hist_bins_sorted_2 ( ) = Alcotest . ( check ( array int ) ) " histogram with infinite bins sorted " [ | 1 ; 2 ; 2 ] | ( To_test . hist_bin_sorted Data . bin2 Data . x2_sorted ) |
let fao = let open Alcotest in let fl = testable Fmt . float ( fun x y -> x = y || abs_float ( x . - y ) <= eps ) in option ( array fl ) |
let hist_bins_weights ( ) = Alcotest . ( check ( pair ( array int ) fao ) ) " weighted histogram with bins " ( [ | 3 ] , | Some [ | 3 . ] ) | ( To_test . hist_bin_weighted Data . bin1 Data . w1 Data . x1 ) |
let hist_bins_weights_sorted ( ) = Alcotest . ( check ( pair ( array int ) fao ) ) " weighted histogram with bins sorted " ( [ | 3 ] , | Some [ | 3 . ] ) | ( To_test . hist_bin_weighted_sorted Data . bin1 Data . w1_sorted Data . x1_sorted ) |
let hist_bins_normalise ( ) = Alcotest . ( check ( pair fao fao ) ) " normalisation test unweighted " ( Some [ | 1 . . / 5 . ; 2 . . / 5 . ; 2 . . / 5 . ] | , Some [ | 1 . . / 5 . ; 2 . . / 5 . . / sqrt 0 . 5 ; 2 . . / 5 ... |
let hist_bins_normalise_weights ( ) = Alcotest . ( check ( pair fao fao ) ) " normalisation test with weights " ( Some [ | 2 . . / 4 . 2 ; 1 . . / 4 . 2 ; 1 . 2 . / 4 . 2 ] | , Some [ | 2 . . / 4 . 2 ; 1 . . / 4 . 2 . / sqrt 0 ... |
let hist_bins_normalise_binf ( ) = Alcotest . ( check ( pair fao fao ) ) " normalisation test unweighted , infinite bins " ( Some [ | 1 . . / 6 . ; 2 . . / 6 . ; 3 . . / 6 . ] , | Some [ | 0 . ; 2 . . / 6 . . / sqrt 0 . 5 ; 0 . ]... |
let tukey_fences ( ) = Alcotest . ( check ( pair ( float 0 . 0 ) ( float 0 . 0 ) ) ) " tukey fences test with data containing outliers " ( - 3 . 0 , 5 . 0 ) ( To_test . tukey_fences Data . with_outliers ) |
let quantiles ( ) = Alcotest . ( check fao ) " quantiles calculation " ( Some [ | 0 . 106500 ; 0 . 190700 ; 0 . 376750 ; 0 . 767625 ; 0 . 978800 ] ) | ( To_test . quantiles ~ p [ :| 0 . ; 0 . 25 ; 0 . 5 ; 0 . 75 ; 1 . ] | [ | 0... |
let test_set = [ " mannwhitneyu_test_left_side_asym " , ` Slow , mannwhitneyu_test_left_side_asym ; " mannwhitneyu_test_right_side_asym " , ` Slow , mannwhitneyu_test_right_side_asym ; " mannwhitneyu_test_both_side_asym " , ` Slow , mannwhitneyu_test_both_side_asym ; " mannwhitn... |
type ( ' a , ' b ) t_iter = ( ' a -> int -> ' b -> ' a ) -> ' a -> int * ' a |
let trace pos = let a , b , c , d = pos in Printf . printf " trace :% s :% d :% d :% d \ n " %! a b c d |
module Cubic = struct type t = { lx : float ; rx : float ; dx : float ; p0 : float ; p1 : float ; p ' 0 : float ; p ' 1 : float ; poly : float array } let f t x = let u = ( x . - t . lx ) . / t . dx in let u2 = u . * u in let u3 = u2 . * u in ( t . poly . ... |
module CdfTree = struct type binary_node = | Leaf of int | Balance of ( float * binary_node * binary_node ) let rec create_node cdf_x_of_p logn p dp i di = if logn <= 0 then Leaf ( i / 2 ) else ( let ndp = dp . / 2 . in let ndi = di / 2 in let node_l = create_node cdf_x_of_p ( logn - ... |
let _ = let tree = CdfTree . create_from_rv ( M . gaussian_cdf ~ mu : 0 . ~ sigma : 1 . ) 5 in CdfTree . display tree ; List . iter ( fun x -> Printf . printf " bucket of % f : % d \ n " x ( CdfTree . value tree x ) ) [ - 1 . ; - 0 . 5 ; 0 . ; 0 . ... |
module Distribution = struct type t = { name : string ; num_buckets : int ; cdf_x_array : float array ; pdf_x_array : float array ; cubics : t_cubic array ; dut_cdf : float -> float ; dut_pdf : float -> float } let create name dut_cdf dut_pdf cdf_x_array pdf_x_array = let num_buckets = Arra... |
module RandomTest = struct type test_hypothesis = { test_name : string ; score_name : string ; hypothesis : M . hypothesis } let make_hypothesis reject p_value score : M . hypothesis = { reject ; p_value ; score } let make_test_hypothesis test_name score_name hypothesis = { test_name ; s... |
module BinaryTest = struct include RandomTest let frequency ( ? significance = 0 . 01 ) ( ? p = 0 . 5 ) iter = let q = 1 . . - p in let inc_if_true_else_dec acc _ b = if b then acc + 1 else acc - 1 in let n , sum = iter inc_if_true_else_dec 0 in let x = float sum . - ( ( (... |
let test_rough_cdf pydist = let ( name , imprecision , dut_cdf , dut_pdf , dut_logcdf , dut_logpdf , dut_opt_ppf , dut_sf , dut_logsf , dut_opt_isf , cdf_x_array , pdf_x_array ) = pydist in let dist = Distribution . create name dut_cdf dut_pdf cdf_x_array pdf_x_array in let sum_diff_cdf_2... |
let test_rough_cdf_matches _ = List . iter test_rough_cdf cdf_approximations ; ( ) |
let _ = Owl_stats_prng . self_init ( ) ; Owl_stats_prng . sfmt_seed 1 |
let one_third = 1 . . / 3 . |
type t_bin_iter = | IOfBool of ( ( int , bool ) t_iter -> RandomTest . test_hypothesis ) | IIIIOfBool of ( ( int * int * int * int , bool ) t_iter -> RandomTest . test_hypothesis ) | IIFIOfBool of ( ( int * int * float * int , bool ) t_iter -> RandomTest . test_hypothesis ... |
let bin_frequency = IOfBool BinaryTest . frequency |
let bin_frequency_1_of_3 = IOfBool ( BinaryTest . frequency ~ p : one_third ) |
let bin_block_frequency_7 = IIFIOfBool ( BinaryTest . block_frequency 7 ) |
let bin_block_frequency_70 = IIFIOfBool ( BinaryTest . block_frequency 70 ) |
let bin_block_frequency_700 = IIFIOfBool ( BinaryTest . block_frequency 700 ) |
let bin_block_frequency_1_of_3_7 = IIFIOfBool ( BinaryTest . block_frequency ~ p : one_third 7 ) |
let bin_block_frequency_1_of_3_70 = IIFIOfBool ( BinaryTest . block_frequency ~ p : one_third 70 ) |
let bin_block_frequency_1_of_3_700 = IIFIOfBool ( BinaryTest . block_frequency ~ p : one_third 700 ) |
let bin_patterns_2 = IIIIOfBool ( BinaryTest . occurrences_of_patterns 8 2 ) |
let bin_patterns_3 = IIIIOfBool ( BinaryTest . occurrences_of_patterns 8 3 ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.