You will be presented with a variety of sequences of real numbers. Your job is to answer the question: "Is this a uniformly distributed sequence of random numbers?"
Only the distribution needs to be examined in this problem. (You do not need to check for autocorrelation.)
Input: x, a row vector of real numbers. Output: y, a Boolean scalar.
Some sequences have been generated by MATLAB's (pseudo)random number generator, such as:
x = 0.062 0.945 0.006 0.301 0.638 0.920 0.043 0.533 0.539 0.292 0.218 0.465 0.826 0.172 0.686 0.040 0.489 0.3950 0.761 0.038
On average these will have a uniform distribution. Thus, by splitting up the sequence into 'bins' we find for the example above there are twelve numbers falling into the 0.0-to-0.5 bin, and a further eight numbers falling into the 0.5-to-1.0 bin. For this length of sequence (a total of twenty numbers), that would be a sufficiently even division to retain the hypothesis that the underlying distribution from which the numbers were sampled was indeed a random, uniform distribution function (UDF). However, please note that it may be necessary to divide the data into more than just two bins.
Other sequences will have been constructed so as to weight unevenly. For example:
x = 7.004 1.002 1.984 3.868 2.048 1.014 1.066 1.337 1.074 60.266 1.008 1.783 2.196 1.065 1.0613 1.049 1.236 1.235 1.394 1.107
has fifteen numbers in the 1.0-to-2.0 bin, but then there are some weird 'outliers' in the remaining five numbers, which reach up to more than 60. It does not seem likely that this would have been generated from a UDF.
Note: the sequences in the examples above were for illustrative purposes; most sequences in the Test Suite are considerably longer.
See also:
Return the 'Size' of a String of Code
116 Solvers
Similar Triangles - find the height of the tree
157 Solvers
44 Solvers
13 Solvers
Is this triangle right-angled?
1419 Solvers
Solution 1945956
The Gaussian distribution is considered a normal distribution of random numbers, so why is it being tested as false in the final test? Logically it should return as true shouldn't it ? My code works on all but the final test which seems reversed to me unless you know something I don't ?