The quality of pseudo random-number generators used in some computations, especially simulation, is a significant issue. Proposed generation algorithms are subjected to many tests to establish their quality, or, more usually, their lack of it. One of the common tests is the run test.
In this test, sequences are tested for ``runs up" and ``runs down."
We will examine series of data values for the ``Up" and ``Down" sequences each series contains.
Within a series, an ``Up" sequence continues as long as each data-value received is not less than the previous data-value. An ``Up" sequence terminates when a data-value received is less than the previous data-value received.
A ``Down" sequence continues as long as each data-value received is not greater than the previous data-value. A ``Down" sequence terminates when a data-value received is greater than the previous data-value received.
An ``Up" sequence can be initiated by the termination of a ``Down" sequence and vice versa. (Sequences initiated in this manner have length one at this initiation point.)
All the initial data-values are part of an ``Up" sequence, and contribute to its length, if the first deviation of the data-values is upwards.
All the initial data-values are part of a ``Down" sequence, and contribute to its length, if the first deviation of the data-values is downwards.
If the data-values received don't allow classification as either an ``Up" or a ``Down" sequence, the data should be considered to have neither sequence.
Find the average length of both the ``Up" and the ``Down" sequences encountered for each input line in the data file. Report these average lengths as each input line is processed.