You could do this as a permutation test:
 
tmp <- unlist(strsplit('HHTHTTTTHHH', ''))
out1 <- c( max(rle(tmp)$lengths), 
 replicate( 999, {tmp2 <- sample(tmp); max(rle(tmp2)$lengths)} ) )
hist(out1)
abline(v=out1[1], col='red')
mean(out1 <= out1[1])
mean(out1 >= out1[1])
 
There may be a better option, but this works and is fairly straight forward.
 
Hope it helps,

________________________________

From: r-help-bounces@r-project.org on behalf of Park, Kyong H Mr ECBC
Sent: Thu 12/27/2007 11:47 AM
To: 'bogdan romocea'
Cc: R-help@stat.math.ethz.ch
Subject: Re: [R] A function for random test based on longest run(UNCLASSI FIED)



Classification:  UNCLASSIFIED
Caveats: NONE

 Thanks for your quick response. The program you mentioned below available
from R is based on number of runs (up or down) not based on a longest length
of runs of same events. To be more specific, for example, from a series,
HHTHTTTTHHH, the number of runs are 5, and the longest length of runs of the
same events is 4. I'll check for the website you mentioned below.

Kyong

-----Original Message-----
From: bogdan romocea [mailto:br44114@gmail.com]
Sent: Thursday, December 27, 2007 12:08 PM
To: kyong.ho.park@us.army.mil
Cc: r-help
Subject: RE: [R] A function for random test based on longest run
(UNCLASSIFIED)

  > require(tseries)
  > ?runs.test
Also, take a look at dieharder, it implements a large number of randomness
tests:
http://www.phy.duke.edu/~rgb/General/dieharder.php



> -----Original Message-----
> From: r-help-bounces@r-project.org
> [mailto:r-help-bounces@r-project.org] On Behalf Of Park, Kyong H Mr
> ECBC
> Sent: Thursday, December 27, 2007 11:05 AM
> To: 'r-help@r-project.org'
> Subject: [R] A function for random test based on longest run
> (UNCLASSIFIED)
>
> Classification:  UNCLASSIFIED
> Caveats: NONE
>
> Hello, R users,
>
> Has anybody written a function for random test based on the length of
> longest run of same events. I really appreciate your help.
>
> Kyong Park
> Classification:  UNCLASSIFIED
> Caveats: NONE
>
>
>       [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
Classification:  UNCLASSIFIED
Caveats: NONE


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



	[[alternative HTML version deleted]]

