R Under development (unstable) (2023-11-26 r85638 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(diptest) > ## These are from > ## the 217-readme.doc file that explains the bug fixed by > ## Ferenc Mechler (fmechler@med.cornell.edu). [5/Sep/2002] > ## > ex1 <- c(0.0198, 0.0198, 0.1961, 0.2898, 0.3184, 0.3687, + 0.4336, 0.4987, 0.5661, 0.6530, 0.7476, 0.8555) > > ex2 <- c(0.0198, 0.1961, 0.2898, 0.3184, 0.3687, 0.4336, + 0.4987, 0.5661, 0.6530, 0.7476, 0.8555, 0.9912) > > ## Multiply them by 10000 here: > > (D1 <- dip(10000*ex1, full=TRUE, debug=2)) dip() in C: n = 12; starting with 2N*dip = 1. 'dip': LOOP-BEGIN: 2n*D= 1 [low,high] = [ 1, 12]; l_lcm/gcm = ( 6, 3) while(gcm[ix] != lcm[iv]) : L(3,2) --> ix = 2, iv = 3 G(2,3) --> ix = 1, iv = 3 --> ix = 1, iv = 4 --> ix = 1, iv = 5 --> ix = 1, iv = 6 calculating dip .. (dip_l, dip_u) = (2, 1) -> new larger dip 2 (j_best = 2) 'dip': LOOP-BEGIN: 2n*D= 2 [low,high] = [ 4, 9]; l_lcm/gcm = ( 6, 2) while(gcm[ix] != lcm[iv]) : L(2,2) --> ix = 1, iv = 3 L(2,3) --> ix = 1, iv = 4 --> ix = 1, iv = 5 --> ix = 1, iv = 6 Call: dip(x = 10000 * ex1, full.result = TRUE, debug = 2) n = 12. Dip statistic, D_n = 0.08333333 = 2/(2n) Modal interval [xL, xU] = [x[4], x[9]] = [2898, 5661] GCM and LCM have 2 and 6 nodes inside [xL, xU], respectively. > str(D1, digits = 10, vec.len = 12) List of 15 $ call : language dip(x = 10000 * ex1, full.result = TRUE, debug = 2) $ x : num [1:12] 198 198 1961 2898 3184 3687 4336 4987 5661 6530 7476 8555 $ n : int 12 $ dip : num 0.08333333333 $ lo.hi : int [1:2] 4 9 $ ifault : int 0 $ gcm : int [1:2] 9 4 $ lcm : int [1:6] 4 5 6 7 8 9 $ mn : int [1:12] 1 1 1 1 4 4 4 4 4 4 4 4 $ mj : int [1:12] 2 9 6 5 6 7 8 9 10 11 12 12 $ min.is.0 : logi FALSE $ debug : int 2 $ xl : num 2898 $ xu : num 5661 $ full.result: logi TRUE - attr(*, "class")= chr "dip" > > (D2 <- dip(10000*ex2, full=TRUE, debug=2)) dip() in C: n = 12; starting with 2N*dip = 1. 'dip': LOOP-BEGIN: 2n*D= 1 [low,high] = [ 1, 12]; l_lcm/gcm = ( 6, 4) while(gcm[ix] != lcm[iv]) : G(3,2) --> ix = 2, iv = 2 G(2,2) --> ix = 1, iv = 2 --> ix = 1, iv = 3 --> ix = 1, iv = 4 --> ix = 1, iv = 5 --> ix = 1, iv = 6 calculating dip .. (dip_l, dip_u) = (1, 1) 'dip': LOOP-BEGIN: 2n*D= 1 [low,high] = [ 3, 8]; l_lcm/gcm = ( 6, 2) while(gcm[ix] != lcm[iv]) : L(2,2) --> ix = 1, iv = 3 L(2,3) --> ix = 1, iv = 4 --> ix = 1, iv = 5 --> ix = 1, iv = 6 calculating dip .. (dip_l, dip_u) = (0, 1) 'dip': LOOP-BEGIN: 2n*D= 1 [low,high] = [ 3, 5]; l_lcm/gcm = ( 3, 2) while(gcm[ix] != lcm[iv]) : L(2,2) --> ix = 1, iv = 3 calculating dip .. (dip_l, dip_u) = (0, 1) 'dip': LOOP-BEGIN: 2n*D= 1 [low,high] = [ 3, 4]; l_lcm/gcm = ( 2, 2) ** (l_lcm,l_gcm) = (2,2) ==> d := 1 calculating dip .. (dip_l, dip_u) = (0, 0) No improvement in low = 3 nor high = 4 --> END Call: dip(x = 10000 * ex2, full.result = TRUE, debug = 2) n = 12. Dip statistic, D_n = 0.04166667 = 1/(2n) Modal interval [xL, xU] = [x[3], x[4]] = [2898, 3184] GCM and LCM have 2 and 2 nodes inside [xL, xU], respectively. > str(D2, digits = 10, vec.len = 12) List of 15 $ call : language dip(x = 10000 * ex2, full.result = TRUE, debug = 2) $ x : num [1:12] 198 1961 2898 3184 3687 4336 4987 5661 6530 7476 8555 9912 $ n : int 12 $ dip : num 0.04166666667 $ lo.hi : int [1:2] 3 4 $ ifault : int 0 $ gcm : int [1:2] 4 3 $ lcm : int [1:2] 3 4 $ mn : int [1:12] 1 1 2 3 3 3 3 3 3 3 3 3 $ mj : int [1:12] 8 5 4 5 6 7 8 9 10 11 12 12 $ min.is.0 : logi FALSE $ debug : int 2 $ xl : num 2898 $ xu : num 3184 $ full.result: logi TRUE - attr(*, "class")= chr "dip" > > proc.time() user system elapsed 0.18 0.12 0.25