Hello all this is my first post on Cross Validated, so please let me know if it is not in an acceptable form.

I have been attempting to analyze a data set where I have a Bernoulli process that is generating a sequence of two outcomes with given probabilities. I am calculating the average length of runs of a given outcome which I believe could be considered a Poisson process for example:

sample sequence= 0,0,0,1,1,0,0,0,0,1,1,1
mean run length=  3

Possible poisson process

This is a plot of some fake data that I generated to illustrate the distribution.

I am then attempting to quantify how the 'streakiness' of this sequence compares to a distribution of other sequences, and I would like the output to be in the form of a standard normal variable. More succinctly: given my sample sequence and the distribution above, how many 'standard deviations' more streaky is the sample sequence than the distribution?

So far I have tried using a Freeman-Tukey transformation e.g.:

$r=sample \ run \ length$

$\mu=mean \ of \ distribution$

$X=\sqrt{r}+\sqrt{r + 1} - \sqrt{4*\mu+1}$

But this is providing some odd output. For example if the run length in the sample is equal to the mean run length of the distribution I would assume X above should be 0 but it is not.

My question is twofold.

  1. Am I correct in assuming that the run lengths above are actually the result of a Poisson process?
  2. If so, Is this the correct "standardizing transformation" for these type of data?
  • $\begingroup$ Thanks for the correction @Nick Cox! That was sloppy writing on my part. $\endgroup$
    – Jacob
    Jan 12 '16 at 22:09

Run lengths in a Bernoulli process will not be Poisson.

The number of 1's until the next 0 is geometric; and the number of 0's to the next 1 is geometric (of the type starting from 0); consequently run-lengths of each type (0's and 1's) will be geometric (of the type starting from 1).

The parameters of these two geometrics will not in general be equal (because $p$ is not always $\frac12$), so if you combine the two kinds of run-length together you'll have a "mixture" of geometrics. However, it's not quite a mixture in the normal sense because it always alternates between each type (i.e. they're sequentially dependent, not independent) - the number of runs of 0's and 1's cannot differ by more than 1.

Nevertheless for very long sequences, we can get the distribution of run lengths readily enough:

$P(R=r) = \frac12[p^{r-1}.(1-p) + (1-p)^{r-1}.p]\,,\: r=1,2,...\: 0<p<1$

Consider simulating a set of runs with $p=0.2$:

 bern.2 <- rbinom(1000000,1,.2)
 t <- rowSums(table(rle(bern.2)))
 x <- as.numeric(names(t))
 r <- 1:max(x)
 pmf <- (.2^(r-1)*.8+.8^(r-1)*.2)/2

which produces the following display of of observed log(proportions) at each run length, as well as logs of the above distribution (pmf):

observed run lengths and pmf for simulated Bernoulli process, log scale on y axis

It shows excellent agreement.

[By contrast, the length of the first run in such a process will have a pmf of $p^r \cdot (1-p) + (1-p)^r\cdot p$.]

Even though the negative answer to the first question removes the need to address the second question, note that even in a Poisson, when $X=\mu$, the Freeman-Tukey transform of $X$ is not quite $0$. Note that $\sqrt{\mu}+\sqrt{\mu+1}\geq\sqrt{4\mu+1}$ for $x\geq 0$, with equality only at $x=0$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.