The following R, S-plus, matlab and java programs compute the distribution and the first moment of the length of the longest k-interrupted run (Lk) in a binary sequence.

  1. LSR-indep.txt (Rcode)

Reports the tail probability of LSR{k} (longest k-interrupted run)  for k=0-3 of a binary sequence obtained from a p-value sequence under independent assumption.

  1. Lkexact.pv (S-plus  program)

Transferred p-value sequence pv is into a binary sequence by the inputted threshold,

and report its longest k-interrupt run Lk, k=0-3 as well as the corresponding

tail probability P(Lk >=w) are reported.

The out also includes goodness of fit tests for markov independence  and 1st order dependence

* The file contains the following subroutine : (1)Lk.length : reports the  max length of well-matching (1) run, allowing #k mismatches within a binary sequence a. (2) Lk.marko.test_function(sq): test if seq is Ho: independent seq vs H1: 1st oreder Markov. (3) Lk.0, Lk.1, Lk.2, Lk.3: compute the probability P(Lk>=d) for k=0~3.  Note that computation time for k=3 is exceptionally longer than smaller k.

  1. Elongrun(n,pb) : outcome : expectation of L (for any k)  #call subroutine : longrun(n,k,pb)
  2. longd0(ps, pss, pff, n, d) : compute the probability P(L0>=d) (S-plus), (JAVA)
  3. longd1(ps, pss, pff, n, d) : compute P(L1>=d) (S-plus) (S-plus) , (JAVA)
  4. longd2(ps, pss, pff, n, d) : compute P(L2>=d) (S-plus)
  5. longd3(ps, pss, pff, n, d) : compute P(L3>=d) (S-plus)
  6. matlab program for P(L0>=d) longd0.m
  7. matlab program for P(L1>=d) longd1.m
  8. matlab program for P(L2>=d) longd2.m
  9. Lksim: reports the length of Lk for k=1-5 (S-plus)
  10. S-plus program to compute the asymptotic probability P(Lk>=d) using Waterman’s formula. (assuming Markov independent)

waterman (ps,n, d, k): need to give ps (the initial probability for 1)

Lk.waterman(a,k): compute the tail probability of Lk for a zero-one binary sequence a.

  1. karlin : reports the asymptotic value of P(Lk>d) using karlin's formula (S-plus)