runstest
              "ud")Run test for randomness in the vector x.
 h = runstest (x) calculates the number of runs of
 consecutive values above or below the mean of x and tests the null
 hypothesis that the values in the data vector x come in random order.
 h is 1 if the test rejects the null hypothesis at the 5% significance
 level, or 0 otherwise.
 h = runstest (x, v) tests the null hypothesis based
 on the number of runs of consecutive values above or below the specified
 reference value v.  Values exactly equal to v are omitted.
 h = runstest (x,  calculates the number of
 runs up or down and tests the null hypothesis that the values in the data
 vector x follow a trend.  Too few runs indicate a trend, while too
 many runs indicate an oscillation.  Values exactly equal to the preceding
 value are omitted.
"ud")
 h = runstest (…, Name, Value) specifies
 additional options to the above tests by one or more Name-Value
 pair arguments.
| Name | Value | |
|---|---|---|
| "alpha" | the significance level. Default is 0.05. | |
| "method" | a string specifying the method used to
 compute the p-value of the test.  It can be either "exact"to use an
 exact algorithm, or"approximate"to use a normal approximation.  The
 default is"exact"for runs above/below, and for runs up/down when
 the length of x is less than or equal to 50.  When testing for runs up/down
 and the length of x is greater than 50, then the default is"approximate", and the"exact"method is not available. | |
| "tail" | a string specifying the alternative hypothesis | 
| "both" | two-tailed (default) | ||
| "left" | left-tailed | ||
| "right" | right-tailed | 
See also: signrank, signtest
Source Code: runstest