<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">OJS</journal-id><journal-title-group><journal-title>Open Journal of Statistics</journal-title></journal-title-group><issn pub-type="epub">2161-718X</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/ojs.2014.42014</article-id><article-id pub-id-type="publisher-id">OJS-43294</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Physics&amp;Mathematics</subject></subj-group></article-categories><title-group><article-title>
 
 
  Numerical Procedures for Calculating the Probabilities of Recurrent Runs
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>.</surname><given-names>P. Silverman</given-names></name><xref ref-type="aff" rid="aff1"><sub>1</sub></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib></contrib-group><aff id="aff1"><label>1</label><addr-line>Department of Physics, Trinity College, Hartford, USA</addr-line></aff><author-notes><corresp id="cor1">* E-mail:<email>mark.silverman@trincoll.edu</email></corresp></author-notes><pub-date pub-type="epub"><day>26</day><month>02</month><year>2014</year></pub-date><volume>04</volume><issue>02</issue><fpage>144</fpage><lpage>153</lpage><history><date date-type="received"><day>October</day>	<month>22,</month>	<year>2013</year></date><date date-type="rev-recd"><day>November</day>	<month>22,</month>	<year>2013</year>	</date><date date-type="accepted"><day>November</day>	<month>30,</month>	<year>2013</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
   Run count statistics serve a central role in tests of non-randomness of stochastic processes of interest to a wide range of disciplines within the physical sciences, social sciences, business and finance, and other endeavors involving intrinsic uncertainty. To carry out such tests, it is often necessary to calculate two kinds of run count probabilities: 1) the probability that a certain number of trials results in a specified multiple occurrence of an event, or 2) the probability that a specified number of occurrences of an event take place within a fixed number of trials. The use of appropriate generating functions provides a systematic procedure for obtaining the distribution functions of these probabilities. This paper examines relationships among the generating functions applicable to recurrent runs and discusses methods, employing symbolic mathematical software, for implementing numerical extraction of probabilities. In addition, the asymptotic form of the cumulative distribution function is derived, which allows accurate runs statistics to be obtained for sequences of trials so large that computation times for extraction of this information from the generating functions could be impractically long. 
 
</p></abstract><kwd-group><kwd>Recurrent Events; Theory of Runs; Time Series Analysis; Generating Functions; Probability Distributions</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><sec id="s1_1"><title>1.1. Runs Tests for Non-Randomness</title><p>A stochastic process generates random outcomes in time or space. Such processes occur widely in the physical and social sciences, as well as in purely practical human activities such as finance, manufacturing, and commerce. Despite their random occurrence―indeed, precisely because of it―the outcomes of a stochastic process will display ordered patterns which a statistically na&#239;ve observer may mistakenly interpret as predictively useful information. In recent years, controversial issues over the information content of time series have arisen in a variety of disciplines such as nuclear physics [<xref ref-type="bibr" rid="scirp.43294-ref1">1</xref>] and econophysics (i.e. dynamics of the stock market) [<xref ref-type="bibr" rid="scirp.43294-ref2">2</xref>]. Although it is not possible to prove with certainty that a particular process is random, there are various statistical tests to demonstrate within specified confidence limits that it is not random. Among these, nonparametric runs tests are especially useful, in part because of their ease of implementation and statistical power [<xref ref-type="bibr" rid="scirp.43294-ref3">3</xref>].</p></sec><sec id="s1_2"><title>1.2. Exclusive Runs</title><p>An exclusive run is an unbroken sequence of similar events, ordinarily of a binary nature. For example, a sequence of symbols aabbbaa comprises 2 runs of a’s of length 2 and 1 run of b’s of length 3. If the events a and b occur with fixed probabilities throughout the sequence, the stochastic process is of the Bernoulli kind, and the distribution theory of binary runs [<xref ref-type="bibr" rid="scirp.43294-ref4">4</xref>] can be used to test for non-randomness in permutational ordering of any such empirical sequence of outcomes.</p><p>It is not necessary for a stochastic process to generate binary events in order to be analyzed for runs. For example, a sequence of n different observations <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x1.png" xlink:type="simple"/></inline-formula> of a continuous random variable will yield <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x2.png" xlink:type="simple"/></inline-formula> sequential differences that are either positive (+) or negative (?) and therefore again subject to binary runs analysis. The binary elements, however, are not Bernoulli variates since the probability of obtaining an element decreases with its position in the unbroken sequence. Nevertheless, one can test for non-randomness in permutational ordering with a different distribution theory [<xref ref-type="bibr" rid="scirp.43294-ref5">5</xref>].</p><p>Although developed initially for testing quality control in manufacturing, exclusive runs and up-down runs have been employed in analysis of a variety of experiments to test the fundamental prediction of quantum mechanics that transitions between quantum states occur randomly [6,7]. A problematic issue in the counting of exclusive or up-down runs is that the length of a run can be changed by future events. Thus, in the succession aabbbaa, the second run of 2 a could change to a run of 3 a or 4 a if the next two trials resulted in ab or aa respectively.</p></sec><sec id="s1_3"><title>1.3. Runs of Recurrent Events</title><p>A third kind of runs analysis, based on Feller’s theory of recurrent events [<xref ref-type="bibr" rid="scirp.43294-ref8">8</xref>], was recently employed to examine certain quantum optical processes for evidence of non-random behavior [<xref ref-type="bibr" rid="scirp.43294-ref9">9</xref>]. A recurrent run of length t, as defined by Feller, is a sequence of non-overlapping, uninterrupted successions of exactly t elements of the same kind. It is distinguished from the other two kinds of runs in that the concept of run length is so defined as to be independent of subsequent trials. For example, in the sequence aaaabaaaaaa, there are two runs of length 4<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x3.png" xlink:type="simple"/></inline-formula>, three runs of length 3<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x4.png" xlink:type="simple"/></inline-formula>, and five runs of length 2<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x5.png" xlink:type="simple"/></inline-formula>. (Analyzed in terms of exclusive runs, there would have been 1 run of a of length 4 and 1 run of a of length 6, provided the sequence ended at the 11<sup>th</sup> trial). In a sequence of Bernoulli trials, a recurrent run of length t occurs at the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x6.png" xlink:type="simple"/></inline-formula> trial if the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x7.png" xlink:type="simple"/></inline-formula> trial adds a new run to the sequence. Thus, the recurrent runs of length 4 occur at positions 4, 9, and the recurrent runs of length 3 occur at positions 3, 8, 11.</p><p>The advantage of Feller’s definition is that runs of a fixed length become recurrent events, and the statistical theory of recurrent events can then be applied to testing empirical data sequences for permutational invariance over a much wider variety of patterns than just those of unbroken sequences of identical binary elements. For example, one may be interested in testing the recurrence of a pattern abab, which, in a quantum optics experiment, might correspond to a sequence of alternate detections of left and right circularly polarized photons, or, in a series of stock price variations, might correspond to a sequence of alternative observations of rising and falling closing prices. Besides the application to runs, the same theoretical foundation may be applied to recurrent events in other forms such as return-to-origin problems, ladder-point problems (instances where a sum of random variables exceeds all preceding sums), and waiting-time problems.</p><p>The theory of recurrent runs, the relevant parts of which are examined in the following section, leads to generating functions from which the probability of a run of defined events of specified length can in principle be calculated exactly. As a practical matter, the extraction of these probabilities requires geometrically longer computation times with increasing sequence length. The availability of fast lap-top computers with large random access memory and of symbolic mathematical software of hitherto unparalleled ability to execute series expansions and perform differentiation and integration provides the analyst with computational power unimaginable to the creators of the statistical theory of runs. I report here mathematical strategies for reducing significantly the computation time for the probability of the widely applicable case of k occurrences of runs of length t in a Bernoulli sequence of length n.</p></sec></sec><sec id="s2"><title>2. Theory and Implementation of Recurrent Runs</title><sec id="s2_1"><title>2.1. Probability Generating Functions</title><p>Following Feller, I define the recurrent event E to be a run of successes of length t in a sequence of Bermoulli trials with p the probability of a single successful outcome and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x8.png" xlink:type="simple"/></inline-formula> the probability of failure. Consider the following random variables:</p><disp-formula id="scirp.43294-formula90749"><label>(1)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x9.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.43294-formula90750"><label>(2)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x10.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.43294-formula90751"><label>. (3)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x11.png"  xlink:type="simple"/></disp-formula><p>The distribution of the variable T is defined by</p><disp-formula id="scirp.43294-formula90752"><label>(4)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x12.png"  xlink:type="simple"/></disp-formula><p>where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x13.png" xlink:type="simple"/></inline-formula> is the probability that E occurs for the first time at the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x14.png" xlink:type="simple"/></inline-formula> trial. The generating function of the probabilities of first occurrence is expressed by</p><disp-formula id="scirp.43294-formula90753"><label>. (5)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x15.png"  xlink:type="simple"/></disp-formula><p>The number of trials to the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x16.png" xlink:type="simple"/></inline-formula> occurrence of E is then characterized by the random variable <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x17.png" xlink:type="simple"/></inline-formula> in (2), which is a sum of the waiting times of k independent trials, from which it is follows that the associated generating function takes the form</p><disp-formula id="scirp.43294-formula90754"><label>(6)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x18.png"  xlink:type="simple"/></disp-formula><p>where</p><disp-formula id="scirp.43294-formula90755"><label>(7)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x19.png"  xlink:type="simple"/></disp-formula><p>is the probability that the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x20.png" xlink:type="simple"/></inline-formula> occurrence of E first takes place at the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x21.png" xlink:type="simple"/></inline-formula> trial.</p><p>I leave to the cited literature the proof that the generating function (5) for runs of length t with individual probability of success p is given by</p><disp-formula id="scirp.43294-formula90756"><label>(8)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x22.png"  xlink:type="simple"/></disp-formula><p>from which the mean and standard deviation of the recurrence times follow by differentiation</p><disp-formula id="scirp.43294-formula90757"><label>(9)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x23.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.43294-formula90758"><label>. (10)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x24.png"  xlink:type="simple"/></disp-formula><p>For economy of expression, the parameters p, t will be suppressed in the arguments of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x25.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x26.png" xlink:type="simple"/></inline-formula>, and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x27.png" xlink:type="simple"/></inline-formula> unless needed to avoid ambiguity. In general, these parameters will be chosen and fixed at the outset of any illustrative applications. Note, too, that to obtain a statistical moment from a probability generating function (pgf), the derivatives are evaluated at<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x28.png" xlink:type="simple"/></inline-formula>, which leads to a sum of terms, whereas to obtain a probability the derivatives are evaluated at<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x29.png" xlink:type="simple"/></inline-formula>, which leads to a single term.</p><p>For many applications the analyst’s interest is not necessarily in the recurrence time (i.e. number of trials) to the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x30.png" xlink:type="simple"/></inline-formula> occurrence of E, but in the probability that E occurs k times in a fixed number n of trials. The relation connecting the two variates is</p><disp-formula id="scirp.43294-formula90759"><label>. (11)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x31.png"  xlink:type="simple"/></disp-formula><p>The probability <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x32.png" xlink:type="simple"/></inline-formula> that k events E occur in n trials is then expressible as</p><disp-formula id="scirp.43294-formula90760"><label>(12)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x33.png"  xlink:type="simple"/></disp-formula><p>and serves in the construction of two pgf’s</p><disp-formula id="scirp.43294-formula90761"><label>(13)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x34.png"  xlink:type="simple"/></disp-formula><p>and</p><disp-formula id="scirp.43294-formula90762"><label>. (14)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x35.png"  xlink:type="simple"/></disp-formula><p>Note that the summation in (13) is over the number of occurrences, whereas the summation in (14) is over the number of trials. The second equality in (14) follows directly from Equation (11). Multiplying both sides of (13) by <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x36.png" xlink:type="simple"/></inline-formula> and summing over n leads to the bivariate generating function</p><disp-formula id="scirp.43294-formula90763"><label>(15)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x37.png"  xlink:type="simple"/></disp-formula><p>from which the probabilities <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x38.png" xlink:type="simple"/></inline-formula> are calculable by series expansion of both sides of the equality.</p><p>A sense of the structure of the formalism can be obtained by considering the case of recurrent runs of length</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x39.png" xlink:type="simple"/></inline-formula>for a stochastic process with<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x40.png" xlink:type="simple"/></inline-formula>. Substitution of these conditions into Equation (8) for <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x41.png" xlink:type="simple"/></inline-formula> yields</p><p>the following rational expression for the right side of Equation (15) and its corresponding Taylor-series expansion</p><disp-formula id="scirp.43294-formula90764"><label>(16)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x42.png"  xlink:type="simple"/></disp-formula><p>to order<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x43.png" xlink:type="simple"/></inline-formula>. Recall that the powers of s designate the number of trials, and the powers of z designate the number of recurrences of runs of length 3. For a fixed power of s, the sum of the coefficients of the powers of z within each bracketed expression equal unity, as they must by the completeness relation for the probability of mutually exclusive outcomes. Note that the first three terms <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x44.png" xlink:type="simple"/></inline-formula> are independent of z―i.e. contain only powers<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x45.png" xlink:type="simple"/></inline-formula>―since there cannot be runs of length 3 in a sequence of no more than 2 trials. For 3 trials, the probability of 0 runs of length 3 is 7/8 and the probability of 1 run of length 3 is 1/8. For 5 trials, however, the probability of 0 runs is 1/4 and the probability of 1 run is 3/4. This pattern persists: (a) to obtain a run of length t, the sequence of trials must be of length<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x46.png" xlink:type="simple"/></inline-formula>, and (b) the greater the number of trials, the higher is the probability of obtaining longer runs.</p></sec><sec id="s2_2"><title>2.2. Moment Generating Functions</title><p>It is not necessary to know the individual <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x47.png" xlink:type="simple"/></inline-formula> to determine the mean number of recurrent runs</p><disp-formula id="scirp.43294-formula90765"><label>(17)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x48.png"  xlink:type="simple"/></disp-formula><p>which, for many applications in the physical sciences and elsewhere, is the experimentally observed quantity of interest. Multiplying both sides of Equation (17) by <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x49.png" xlink:type="simple"/></inline-formula> and summing n over the range <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x50.png" xlink:type="simple"/></inline-formula> leads to the generating function for the distribution of <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x51.png" xlink:type="simple"/></inline-formula></p><disp-formula id="scirp.43294-formula90766"><label>. (18)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x52.png"  xlink:type="simple"/></disp-formula><p>Starting from the relation</p><disp-formula id="scirp.43294-formula90767"><label>(19)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x53.png"  xlink:type="simple"/></disp-formula><p>and following the same procedure that led to (18) yields the generating function for the distribution <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x54.png" xlink:type="simple"/></inline-formula></p><disp-formula id="scirp.43294-formula90768"><label>. (20)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x55.png"  xlink:type="simple"/></disp-formula><p>From the generating functions (18) and (20) one can deduce the asymptotic relations for mean and variance</p><disp-formula id="scirp.43294-formula90769"><label>(21)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x56.png"  xlink:type="simple"/></disp-formula><p>and</p><disp-formula id="scirp.43294-formula90770"><label>. (22)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x57.png"  xlink:type="simple"/></disp-formula></sec><sec id="s2_3"><title>2.3. Numerical Procedures</title><p>The statistics (probabilities and expectation values) for any physically meaningful choice of probability of success p, run length t, and number of trials n are deducible exactly from expressions (15) and (18) in the manner previously illustrated. For many applications, however, particularly where it is possible to accumulate long sequences of data as is often the case in atomic, nuclear and elementary particle physics experiments or investigations of stock market time series, the tests for evidence of non-random behavior are best made by examining long runs. Suppose, for example, one wanted the probability of obtaining the number of occurrences of runs of length 50 in a sequence of 100 trials. One approach, leading directly to all non-vanishing probabilities, would be to extract the 100<sup>th</sup> term</p><disp-formula id="scirp.43294-formula90771"><graphic  xlink:href="http://html.scirp.org/file/4-1240257x58.png"  xlink:type="simple"/></disp-formula><p>from the series expansion of the bivariate generating function (15). Powerful symbolic mathematical software such as Maple or Mathematica permits one to do this up to a certain order limited by the speed and memory of one’s computer, but these calculational tools may become insufficient when one is seeking exact probabilities of runs in data sequences of thousands to millions of bits.</p><p>Using complex variable theory, one can extract expressions for <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x59.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x60.png" xlink:type="simple"/></inline-formula> by evaluation of contour integrals</p><disp-formula id="scirp.43294-formula90772"><label>(23)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x61.png"  xlink:type="simple"/></disp-formula><p>and similarly</p><disp-formula id="scirp.43294-formula90773"><label>(24)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x62.png"  xlink:type="simple"/></disp-formula><p>where C is the unit circle and the generating function<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x63.png" xlink:type="simple"/></inline-formula>, given by Equation (8), specifies the single-event probability p and run length t. Contrary to first impression, however, the execution of expressions (23) or (24) for <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x64.png" xlink:type="simple"/></inline-formula> or <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x65.png" xlink:type="simple"/></inline-formula> directly by differentiation, instead of by a series expansion of the corresponding generators up to the order that yields the desired <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x66.png" xlink:type="simple"/></inline-formula> or<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x67.png" xlink:type="simple"/></inline-formula>, is not computationally economic. The computer, in fact, executes the series expansion of the generator much more rapidly than it performs symbolic differentiation.</p><p>Because the generator <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x68.png" xlink:type="simple"/></inline-formula> [Equation (18)] is univariate, one can take advantage of the rapidity with which symbolic mathematical software executes a series expansion to obtain exact values <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x69.png" xlink:type="simple"/></inline-formula> for very long sequence lengths by the following simple procedure:</p><p>1) For given p and t, express <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x70.png" xlink:type="simple"/></inline-formula> as a rational function <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x71.png" xlink:type="simple"/></inline-formula> of s.</p><p>2) Convert <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x72.png" xlink:type="simple"/></inline-formula> to a power series<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x73.png" xlink:type="simple"/></inline-formula>. In Maple this can be done by the command</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x74.png" xlink:type="simple"/></inline-formula>where the ellipsis <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x75.png" xlink:type="simple"/></inline-formula> represents either the expression to be converted or the Maple equation number of that expression.</p><p>3) Extract the single desired term<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x76.png" xlink:type="simple"/></inline-formula>. In Maple this can be done by filtering the sum:<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x77.png" xlink:type="simple"/></inline-formula>.</p><p>Alternatively, one can convert the series generated to order <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x78.png" xlink:type="simple"/></inline-formula> to a polynomial of degree n, and use the command lcoeff to extract the leading coefficient of the polynomial.</p><p>As an illustration, consider the calculation (by means of Maple) of the exact mean number of runs of length <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x79.png" xlink:type="simple"/></inline-formula> in a sequence of 1 million trials with probability of success<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x80.png" xlink:type="simple"/></inline-formula>. Following the foregoing steps, we have</p><p>1) <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x81.png" xlink:type="simple"/></inline-formula></p><p>2) <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x82.png" xlink:type="simple"/></inline-formula></p><p>3) <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x83.png" xlink:type="simple"/></inline-formula></p><p>where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x84.png" xlink:type="simple"/></inline-formula> is to be replaced by the actual <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x85.png" xlink:type="simple"/></inline-formula> numerical element in the sum obtained in step (2). The arrow, inserted by the author, symbolically points to the form of the output. Extraction of this element for the specified conditions led to <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x86.png" xlink:type="simple"/></inline-formula> in a fraction of a second. In Maple, the command evalf calls for numerical evaluation of expressions; omitting this command results in an exact fraction, which for a sequence length of 1 million is too unwieldy to be useful. Use of the command lcoeff yields the same result, but executes more slowly for large n.</p><p>The procedure described above for converting the rational expression of s into a formal power series in s did not work with the bivariate generator<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x87.png" xlink:type="simple"/></inline-formula>, which involved a product of z with a power of s (depending on run length t) in the denominator, and required, for the conversion, solution of the roots of a high-order (&gt;2) algebraic equation. Maple did return, however, the recursion relation for the coefficients of the formal power series. An alternative procedure to isolate the values <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x88.png" xlink:type="simple"/></inline-formula> for fixed n, which still relied on the computational speed of series expansion and worked well for sequence lengths in the thousands, is the following:</p><p>1) For given p and t, express <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x89.png" xlink:type="simple"/></inline-formula> as a rational function of s and z.</p><p>2) Generate a series expansion of <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x90.png" xlink:type="simple"/></inline-formula> to order n and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x91.png" xlink:type="simple"/></inline-formula>.</p><p>3) Convert the series expansions into polynomials <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x92.png" xlink:type="simple"/></inline-formula> and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x93.png" xlink:type="simple"/></inline-formula>.</p><p>4) Subtract one polynomial from the other to obtain an expression of the form</p><disp-formula id="scirp.43294-formula90774"><graphic  xlink:href="http://html.scirp.org/file/4-1240257x94.png"  xlink:type="simple"/></disp-formula><p>where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x95.png" xlink:type="simple"/></inline-formula> is the largest integer k such that<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x96.png" xlink:type="simple"/></inline-formula>. The coefficients <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x97.png" xlink:type="simple"/></inline-formula> are given as exact fractions.</p><p>5) Evaluate the set <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x98.png" xlink:type="simple"/></inline-formula> as floating-point numbers, if desired.</p><p>As an example, the procedure led in under 10 seconds to the full set <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x99.png" xlink:type="simple"/></inline-formula> for the probability of k occurrences of runs of length 4 in a sequence of 1000 trials. The calculations described in this section were performed with a laptop computer (Intel-based Mac Powerbook) running Maple 16.</p><p>One final procedure, particularly suitable when only selected probabilities of the full set <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x100.png" xlink:type="simple"/></inline-formula> are desired, is to obtain these probabilities directly from the generating function <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x101.png" xlink:type="simple"/></inline-formula> in (14). As in the previous examples, this can be accomplished in either of two ways: (1) by evaluating the leading coefficient of the polynomial in the desired degree n, or (2) by filtering the power series for the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x102.png" xlink:type="simple"/></inline-formula> term. As an example, consider the probability <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x103.png" xlink:type="simple"/></inline-formula> for obtaining 4 runs of length <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x104.png" xlink:type="simple"/></inline-formula> in a series of 100 trials with probability of success<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x105.png" xlink:type="simple"/></inline-formula>. The generating function then takes the form</p><disp-formula id="scirp.43294-formula90775"><graphic  xlink:href="http://html.scirp.org/file/4-1240257x106.png"  xlink:type="simple"/></disp-formula><p>In Maple, method (1) proceeds as follows:</p><p>1) <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x107.png" xlink:type="simple"/></inline-formula></p><p>2) <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x108.png" xlink:type="simple"/></inline-formula></p><p>where the ellipsis is to be replaced by the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x109.png" xlink:type="simple"/></inline-formula> term produced in step (1). In using Maple to execute method (2), one proceeds in a single step once the rational expression <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x109.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x110.png" xlink:type="simple"/></inline-formula> has been obtained:</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x111.png" xlink:type="simple"/></inline-formula>.</p><p>Note that the series must be expanded to <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x112.png" xlink:type="simple"/></inline-formula> terms in order to obtain the coefficient of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x112.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x113.png" xlink:type="simple"/></inline-formula>, since the summation index begins at 0.</p></sec></sec><sec id="s3"><title>3. Generating Function of Cumulative Probability</title><p>For many applications in the physical sciences and elsewhere, the full set of probabilities <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x114.png" xlink:type="simple"/></inline-formula> provides more information than is desirable or usable. Moreover, because <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x114.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x115.png" xlink:type="simple"/></inline-formula> for large k may be very small and the variance relatively large, the more observationally stable statistic is the probability of obtaining k or more occurrences of the specified event, or in other words, the complementary cumulative probability (ccp)</p><disp-formula id="scirp.43294-formula90776"><label>(25)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x116.png"  xlink:type="simple"/></disp-formula><p>introduced in Equation (11). Experimental situations calling for preferential usage of a cumulative probability distribution over a probability function abound in the physical sciences, as, for example, in the analysis of fragmentation [<xref ref-type="bibr" rid="scirp.43294-ref10">10</xref>] and other stochastic processes leading to a power-law distribution.</p><p>The generating function for the ccp is derivable from <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x117.png" xlink:type="simple"/></inline-formula> by summing over the recurrence index k</p><disp-formula id="scirp.43294-formula90777"><label>. (26)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x118.png"  xlink:type="simple"/></disp-formula><p>(It is understood that<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x119.png" xlink:type="simple"/></inline-formula>, and therefore<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x119.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x120.png" xlink:type="simple"/></inline-formula>, are also functions of p and t). Thus, one can calculate <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x119.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x120.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x121.png" xlink:type="simple"/></inline-formula> directly from the generator (26) by use of the methods previously described. A modern laptop running Maple can return results for <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x119.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x120.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x121.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x122.png" xlink:type="simple"/></inline-formula> within minutes for sequence lengths n on the order of many 1000’s.</p></sec><sec id="s4"><title>4. Asymptotic Distributions</title><p>One can show by application of the Central Limit Theorem (CLT) to relation (11) that for sufficiently large number of trials n and number of occurrences k, the number <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x123.png" xlink:type="simple"/></inline-formula> of runs of length t produced in n trials is approximately normally distributed with mean and variance given by relations (21) and (22). The approximation, whose relative accuracy improves in the limit of increasing n, is actually quite good even for modest values of n, as shown in <xref ref-type="table" rid="table1"><xref ref-type="table" rid="table">Table </xref>1</xref> for<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x123.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x124.png" xlink:type="simple"/></inline-formula>. Expansion of the generating function <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x123.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x124.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x125.png" xlink:type="simple"/></inline-formula> yielded the exact mean value as an integer or fraction, which was then expressed as a floating-point number to three significant figures for comparison with the Gaussian approximation. It is to be noted from the <xref ref-type="table" rid="table">Table </xref>that the Gaussian approximation overstates the mean values, and that the absolute error<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x123.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x124.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x125.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x126.png" xlink:type="simple"/></inline-formula>, in contrast to the relative error <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x123.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x124.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x125.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x126.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x127.png" xlink:type="simple"/></inline-formula> increases with run length and number of trials.</p><p>The Gaussian approximation, however, does not work well in estimating the cumulative probability <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x128.png" xlink:type="simple"/></inline-formula> for large n and long runs. However, one can obtain substantial improvement by taking account of the asymptotic behavior of <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x128.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x129.png" xlink:type="simple"/></inline-formula> and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x128.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x129.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x130.png" xlink:type="simple"/></inline-formula>, and the equivalence in Equation (11). Expansion in probability p for fixed run length t of expressions (9) and (10) yields the series</p><disp-formula id="scirp.43294-formula90778"><label>(27)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x131.png"  xlink:type="simple"/></disp-formula><p>in which the constant <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x132.png" xlink:type="simple"/></inline-formula> is orders of magnitude smaller than the leading terms. Thus, in practical terms, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x132.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x133.png" xlink:type="simple"/></inline-formula>and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x132.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x133.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x134.png" xlink:type="simple"/></inline-formula> are virtually equal for long runs, as illustrated in <xref ref-type="table" rid="table">Table </xref>2 for<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x132.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x133.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x134.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x135.png" xlink:type="simple"/></inline-formula>.</p><p>Recall that <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x136.png" xlink:type="simple"/></inline-formula> and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x136.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x137.png" xlink:type="simple"/></inline-formula>, which were derived from the generating function<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x136.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x137.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x138.png" xlink:type="simple"/></inline-formula>, are respectively the mean number of trials to the first occurrence of event E, which is a run of length t. The equivalence of the mean and standard deviation suggests that the asymptotic distribution of the random variable <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x136.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x137.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x138.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x139.png" xlink:type="simple"/></inline-formula> in Equation (1) is exponential [<xref ref-type="bibr" rid="scirp.43294-ref11">11</xref>] <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x136.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x137.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x138.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x139.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x140.png" xlink:type="simple"/></inline-formula>with parameter<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x136.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x137.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x138.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x139.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x140.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x141.png" xlink:type="simple"/></inline-formula>. Then the random variable <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x136.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x137.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x138.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x139.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x140.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x141.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x142.png" xlink:type="simple"/></inline-formula> in Equation (2),</p><p>which is a sum of k independent exponential random variables<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x143.png" xlink:type="simple"/></inline-formula>, follows a gamma distribution</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x144.png" xlink:type="simple"/></inline-formula>with cumulative probability function</p><disp-formula id="scirp.43294-formula90779"><label>(28)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x145.png"  xlink:type="simple"/></disp-formula><table-wrap id="table1" ><label><xref ref-type="table" rid="table1"><xref ref-type="table" rid="table">Table </xref>1</xref></label><caption><title> Comparison of exact and Gaussian mean numbers of runs for n = 100 trials with p = 0.5</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Run Length t</th><th align="center" valign="middle" >Mean Number of Runs (Exact)</th><th align="center" valign="middle" >Mean Number of Runs (Gaussian Approximation)</th></tr></thead><tr><td align="center" valign="middle" >1</td><td align="center" valign="middle" >50</td><td align="center" valign="middle" >50</td></tr><tr><td align="center" valign="middle" >2</td><td align="center" valign="middle" >16.556</td><td align="center" valign="middle" >16.667</td></tr><tr><td align="center" valign="middle" >3</td><td align="center" valign="middle" >7.041</td><td align="center" valign="middle" >7.143</td></tr><tr><td align="center" valign="middle" >4</td><td align="center" valign="middle" >3.258</td><td align="center" valign="middle" >3.333</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >1.562</td><td align="center" valign="middle" >1.613</td></tr><tr><td align="center" valign="middle" >6</td><td align="center" valign="middle" >7.611 (−1)</td><td align="center" valign="middle" >7.937 (−1)</td></tr><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >3.738 (−1)</td><td align="center" valign="middle" >3.937 (−1)</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >1.842 (−1)</td><td align="center" valign="middle" >1.961 (−1)</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >9.098 (−2)</td><td align="center" valign="middle" >9.785 (−2)</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >4.496 (−2)</td><td align="center" valign="middle" >4.888 (−2)</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >2.222 (−2)</td><td align="center" valign="middle" >2.443 (−2)</td></tr><tr><td align="center" valign="middle" >12</td><td align="center" valign="middle" >1.099 (−2)</td><td align="center" valign="middle" >1.221 (−2)</td></tr><tr><td align="center" valign="middle" >13</td><td align="center" valign="middle" >5.433 (−3)</td><td align="center" valign="middle" >6.104 (−3)</td></tr><tr><td align="center" valign="middle" >14</td><td align="center" valign="middle" >2.686 (−3)</td><td align="center" valign="middle" >3.052 (−3)</td></tr><tr><td align="center" valign="middle" >15</td><td align="center" valign="middle" >1.328 (−3)</td><td align="center" valign="middle" >1.526 (−3)</td></tr><tr><td align="center" valign="middle" >16</td><td align="center" valign="middle" >6.561 (−4)</td><td align="center" valign="middle" >7.630 (−4)</td></tr><tr><td align="center" valign="middle" >17</td><td align="center" valign="middle" >3.243 (−4)</td><td align="center" valign="middle" >3.815 (−4)</td></tr><tr><td align="center" valign="middle" >18</td><td align="center" valign="middle" >1.602 (−4)</td><td align="center" valign="middle" >1.907 (−4)</td></tr><tr><td align="center" valign="middle" >19</td><td align="center" valign="middle" >7.916 (−5)</td><td align="center" valign="middle" >9.537 (−5)</td></tr><tr><td align="center" valign="middle" >20</td><td align="center" valign="middle" >3.910 (−5)</td><td align="center" valign="middle" >4.768 (−5)</td></tr><tr><td align="center" valign="middle" >40</td><td align="center" valign="middle" >2.819 (−11)</td><td align="center" valign="middle" >4.547 (−11)</td></tr><tr><td align="center" valign="middle" >60</td><td align="center" valign="middle" >1.820 (−17)</td><td align="center" valign="middle" >4.337 (−17)</td></tr></tbody></table></table-wrap><table-wrap id="table2" ><label><xref ref-type="table" rid="table">Table </xref>2</label><caption><title> Asymptotic mean and SD of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x146.png" xlink:type="simple"/></inline-formula></title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Run Length t</th><th align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x147.png" xlink:type="simple"/></inline-formula></th><th align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x148.png" xlink:type="simple"/></inline-formula></th></tr></thead><tr><td align="center" valign="middle" >1</td><td align="center" valign="middle" >2.00</td><td align="center" valign="middle" >1.41</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >62.00</td><td align="center" valign="middle" >58.22</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >2046.00</td><td align="center" valign="middle" >2037.47</td></tr><tr><td align="center" valign="middle" >20</td><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x149.png" xlink:type="simple"/></inline-formula></td><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x150.png" xlink:type="simple"/></inline-formula></td></tr><tr><td align="center" valign="middle" >30</td><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x151.png" xlink:type="simple"/></inline-formula></td><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x152.png" xlink:type="simple"/></inline-formula></td></tr></tbody></table></table-wrap><p>where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x153.png" xlink:type="simple"/></inline-formula> is the standard gamma function equal to <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x153.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x154.png" xlink:type="simple"/></inline-formula> for integer k.</p><p>By virtue of equivalence (11), Equation (28) also yields a closed-form asymptotic relation for the sought-for cumulative probability distribution<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x155.png" xlink:type="simple"/></inline-formula>.</p><p>Consider, for example, the probability of 1 or more runs of length 20 in 2000 trials with individual probability of success 0.5. A comparison of the results of (a) Equation (28), (b) the cumulative Gaussian distribution with mean and variance given by relations (21) and (22), and (c) the exact calculation obtained from the generating function (26)</p><disp-formula id="scirp.43294-formula90780"><graphic  xlink:href="http://html.scirp.org/file/4-1240257x156.png"  xlink:type="simple"/></disp-formula><p>supports the distribution (28). If the number of trials is increased to 10<sup>6</sup>, the Gamma and Gaussian asymptotic distributions lead to comparable results</p><disp-formula id="scirp.43294-formula90781"><graphic  xlink:href="http://html.scirp.org/file/4-1240257x157.png"  xlink:type="simple"/></disp-formula><p>but the former is still superior to the latter when compared to the probability calculated from the exact generating function.</p><p>The relation (28), by which one can calculate the cumulative probability <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x158.png" xlink:type="simple"/></inline-formula> for large values of n, also allows one to calculate the individual probabilities <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x158.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x159.png" xlink:type="simple"/></inline-formula> as a function of number of occurrences k through the identity</p><disp-formula id="scirp.43294-formula90782"><label>(29)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/4-1240257x160.png"  xlink:type="simple"/></disp-formula></sec><sec id="s5"><title>5. Conclusions</title><p>The theory of recurrent runs provides a statistical basis for rejecting the hypothesis that a series of observations (in time or space) are random. This is a matter that often arises in experimental investigations in atomic, optical, nuclear, and elementary particle physics, as well as in other sciences, finance, and commerce, which may entail a very large number―perhaps in the thousands to millions―of trials or observations.</p><p>In this paper theoretical and numerical methods based on different generating functions were derived and investigated to determine (a) the probability <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x161.png" xlink:type="simple"/></inline-formula> for k recurrence runs of length t in n Bernoulli trials, (b) the complementary cumulative probability<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x161.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x162.png" xlink:type="simple"/></inline-formula>, and (c) the mean number of runs<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x161.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x162.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x163.png" xlink:type="simple"/></inline-formula>.</p><p>The methods reported here can be implemented on modern laptop computers running commercially available symbolic mathematical software, such as Maple (which was the application used by the author). Computation times for application of these methods to data sequences up to millions of trials could range from seconds to minutes.</p><p>To compute runs statistics for sequences of intermediate to very long trial numbers, the asymptotic distribution for the number of trials up to and including the <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x164.png" xlink:type="simple"/></inline-formula> occurrence <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x164.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x165.png" xlink:type="simple"/></inline-formula> of a specified run length t was derived and found to be a Gamma distribution <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x164.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x165.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x166.png" xlink:type="simple"/></inline-formula> to excellent approximation. In the limit of very large (technically, infinite) n and k, the Central Limit Theorem (CLT) predicts an asymptotic distribution <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x164.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x165.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x166.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x167.png" xlink:type="simple"/></inline-formula> of Gaussian form. Both the Gamma and Gaussian asymptotic distributions give comparable results for <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x164.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x165.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x166.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x167.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-1240257x168.png" xlink:type="simple"/></inline-formula> under these circumstances, but the Gaussian approximation is less accurate and fails entirely for values of n and k for which the CLT does not apply.</p></sec></body><back><ref-list><title>References</title><ref id="scirp.43294-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">M. P. Silverman and W. Strange, “Search for Correlated Fluctuations in the β+ Decay of Na-22,” Europhysics Letters, Vol. 87, No. 3, 2009, pp. 32001-32006. http://dx.doi.org/10.1209/0295-5075/87/32001</mixed-citation></ref><ref id="scirp.43294-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">D. Sornette, “Critical Market Crashes,” Physics Reports, Vol. 378, No. 1, 2003, pp. 1-98.http://dx.doi.org/10.1016/S0370-1573(02)00634-8</mixed-citation></ref><ref id="scirp.43294-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">J. Wolfowitz, “On the Theory of Runs with Some Applications to Quality Control,” The Annals of Mathematical Statistics, Vol. 14, No. 3, 1943, pp. 380-288. http://dx.doi.org/10.1214/aoms/1177731421</mixed-citation></ref><ref id="scirp.43294-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">A. M. Mood, “The Distribution Theory of Runs,” The Annals of Mathematical Statistics, Vol. 11, No. 4, 1940, pp. 367-392.http://dx.doi.org/10.1214/aoms/1177731825</mixed-citation></ref><ref id="scirp.43294-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">H. Levene and J. Wolfowitz, “The Covariance Matrix of Runs Up and Down,” The Annals of Mathematical Statistics, Vol. 15, No. 1, 1944, pp. 58-69. http://dx.doi.org/10.1214/aoms/1177731314</mixed-citation></ref><ref id="scirp.43294-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">M. P. Silverman, W. Strange, C. Silverman and T. C. Lipscombe, “Tests for Randomness of Spontaneous Quantum Decay,” Physical Review A, Vol. 61, No. 4, 2000, Article ID: 042106. http://dx.doi.org/10.1103/PhysRevA.61.042106</mixed-citation></ref><ref id="scirp.43294-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">M. P. Silverman and W. Strange, “Experimental Tests for Randomness of Quantum Decay Examined as a Markov Process,” Physics Letters A, Vol. 272, No. 1-2, 2000, pp. 1-9. http://dx.doi.org/10.1016/S0375-9601(00)00374-1</mixed-citation></ref><ref id="scirp.43294-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">W. Feller, “Fluctuation Theory of Recurrent Events,” Transactions of the American Mathematical Society, Vol. 67, 1949, pp. 98-119. http://dx.doi.org/10.1090/S0002-9947-1949-0032114-7</mixed-citation></ref><ref id="scirp.43294-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">D. Branning, A. Katcher, W. Strange and M. P. Silverman, “Search for Patterns in Sequences of Single-Photon Polarization Measurements,” Journal of the Optical Society of America B, Vol. 28, No. 6, 2011, pp. 1423-1430.http://dx.doi.org/10.1364/JOSAB.28.001423</mixed-citation></ref><ref id="scirp.43294-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">M. P. Silverman, W. Strange, J. Bower and L. Ikejimba, “Fragmentation of Explosively Metastable Glass,” Physica Scripta, Vol. 85, 2012, Article ID: 065403. http://dx.doi.org/10.1088/0031-8949/85/06/065403</mixed-citation></ref><ref id="scirp.43294-ref11"><label>11</label><mixed-citation publication-type="other" xlink:type="simple">A. M. Mood, F. A. Graybill and D. C. Boes, “Introduction to the Theory of Statistics,” 3rd Edition, McGraw-Hill, New York, 1974, pp. 540-541.</mixed-citation></ref></ref-list></back></article>