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: [EMAIL PROTECTED] on behalf of Park, Kyong H Mr ECBC
Sent: Thu 12/27/2007 11:47 AM
To: 'bogdan romocea'
Cc: [EMAIL PROTECTED]
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:[EMAIL PROTECTED]
Sent: Thursday, December 27, 2007 12:08 PM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] 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]]

______________________________________________
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.

Reply via email to