Cody

# Problem 44435. Testing for randomness: uniform distribution of real numbers (distribution checking)

Solution 1945947

Submitted on 22 Sep 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
% Random, short faults = 0; isRandom_C = true; for i = 1 : 10 x = 1000 * rand(1, 20+randi(10)); isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = 9 9 5 1 other = 1 len = 24 other = 1 binsiz = 4 bins = 7 6 12 1 other = 1 len = 26 other = 1 binsiz = 4 bins = 13 8 7 other = 1 len = 28 other = 1 binsiz = 3 bins = 8 8 9 other = 1 len = 25 other = 1 binsiz = 3 bins = 10 7 9 other = 1 len = 26 other = 1 binsiz = 3 bins = 11 11 8 other = 1 len = 30 other = 1 binsiz = 3 bins = 11 8 7 3 other = 1 len = 29 other = 1 binsiz = 4 bins = 7 9 8 2 other = 1 len = 26 other = 1 binsiz = 4 bins = 10 6 10 3 other = 1 len = 29 other = 1 binsiz = 4 bins = 7 9 6 2 other = 1 len = 24 other = 1 binsiz = 4

2   Pass
% Bimodal, short faults = 0; isRandom_C = false; for i = 1 : 10 x = [rand(1, 10+randi(5)), 999 + rand(1, 10+randi(5))]; isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = 13 12 other = 1 len = 25 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 14 12 other = 1 len = 26 other = 1 binsiz = 2 y = logical 0 bins = 13 15 other = 1 len = 28 other = 1 binsiz = 2 y = logical 0 bins = 11 13 other = 1 len = 24 other = 1 binsiz = 2 y = logical 0 bins = 14 12 other = 1 len = 26 other = 1 binsiz = 2 y = logical 0 bins = 14 14 other = 1 len = 28 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 11 11 other = 1 len = 22 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 12 12 other = 1 len = 24 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 12 14 other = 1 len = 26 other = 1 binsiz = 2 y = logical 0 bins = 13 15 other = 1 len = 28 other = 1 binsiz = 2 y = logical 0

3   Pass
% Random, medium faults = 0; isRandom_C = true; for i = 1 : 10 x = randi(1000) + 1000 * rand(1, 100+randi(10)); isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = 10 17 19 18 24 18 other = 1 len = 106 other = 1 binsiz = 6 bins = 27 14 19 26 22 other = 1 len = 108 other = 1 binsiz = 5 bins = 13 22 21 19 22 9 other = 1 len = 106 other = 1 binsiz = 6 bins = 9 25 20 16 23 9 other = 1 len = 102 other = 1 binsiz = 6 bins = 5 21 24 16 23 16 other = 1 len = 105 other = 1 binsiz = 6 bins = 14 18 20 26 19 12 other = 1 len = 109 other = 1 binsiz = 6 bins = 17 23 10 22 24 9 other = 1 len = 105 other = 1 binsiz = 6 bins = 14 25 18 22 21 8 other = 1 len = 108 other = 1 binsiz = 6 bins = 13 27 18 17 25 10 other = 1 len = 110 other = 1 binsiz = 6 bins = 14 16 24 21 26 3 other = 1 len = 104 other = 1 binsiz = 6

4   Pass
% Bimodal, medium faults = 0; isRandom_C = false; for i = 1 : 10 x = randi(1000) + [rand(1, 50+randi(5)), 999 + rand(1, 50+randi(5))]; isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = 51 0 0 51 other = 1 len = 102 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 52 0 0 54 other = 1 len = 106 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 54 0 0 0 51 other = 1 len = 105 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 54 0 0 53 other = 1 len = 107 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 51 0 0 0 53 other = 1 len = 104 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 52 0 0 53 other = 1 len = 105 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 54 0 0 0 51 other = 1 len = 105 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 53 0 0 55 other = 1 len = 108 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 51 0 0 52 other = 1 len = 103 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 51 0 0 0 54 other = 1 len = 105 other = 1 binsiz = 5 y = logical 0 y = logical 0

5   Pass
% Skewed, medium faults = 0; isRandom_C = false; for i = 1 : 10 x = 10 ./ rand(1, 100+randi(10)); isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = 99 1 0 0 0 0 0 0 0 1 0 1 other = 1 len = 102 other = 1 binsiz = 12 y = logical 0 bins = 100 5 3 0 0 0 0 1 0 1 other = 1 len = 110 other = 1 binsiz = 10 y = logical 0 bins = 85 8 4 1 1 1 0 1 other = 1 len = 101 other = 1 binsiz = 8 y = logical 0 bins = 85 9 5 1 1 1 0 0 1 other = 1 len = 103 other = 1 binsiz = 9 y = logical 0 bins = 94 6 7 0 0 0 0 0 0 0 1 other = 1 len = 108 other = 1 binsiz = 11 y = logical 0 bins = 91 6 2 0 2 0 0 0 0 1 other = 1 len = 102 other = 1 binsiz = 10 y = logical 0 bins = 82 8 4 4 2 1 0 0 1 1 other = 1 len = 103 other = 1 binsiz = 10 y = logical 0 bins = 97 3 2 0 0 0 0 1 0 0 1 other = 1 len = 104 other = 1 binsiz = 11 y = logical 0 bins = 100 3 0 0 0 2 0 0 0 0 0 0 1 other = 1 len = 106 other = 1 binsiz = 13 y = logical 0 bins = 101 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 104 other = 1 binsiz = 18 y = logical 0

6   Pass
% Random, long faults = 0; isRandom_C = true; for i = 1 : 10 x = 1000 * rand(1, 500+randi(10)); isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = 45 53 47 49 59 54 53 47 46 49 other = 1 len = 502 other = 1 binsiz = 10 bins = 41 54 57 47 53 44 48 45 58 57 other = 1 len = 504 other = 1 binsiz = 10 bins = 55 47 42 40 53 60 61 52 49 44 other = 1 len = 503 other = 1 binsiz = 10 bins = 62 49 59 49 66 49 42 40 45 49 other = 1 len = 510 other = 1 binsiz = 10 bins = 50 41 54 50 48 67 47 42 53 53 other = 1 len = 505 other = 1 binsiz = 10 bins = 43 42 66 66 44 57 35 54 45 50 other = 1 len = 502 other = 1 binsiz = 10 bins = 45 52 59 43 36 61 57 47 55 48 other = 1 len = 503 other = 1 binsiz = 10 bins = 39 50 56 44 54 52 48 54 47 59 other = 1 len = 503 other = 1 binsiz = 10 bins = 46 60 63 53 46 54 45 49 43 43 other = 1 len = 502 other = 1 binsiz = 10 bins = 48 47 57 50 41 54 53 48 63 42 other = 1 len = 503 other = 1 binsiz = 10

7   Pass
% Skewed (1), long faults = 0; isRandom_C = false; for i = 1 : 10 x = 10 ./ rand(1, 500+randi(5)) - randi(1000); isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = Columns 1 through 29 476 16 3 3 1 2 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 504 other = 1 binsiz = 50 y = logical 0 bins = Columns 1 through 29 393 98 6 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 1 0 0 0 0 0 0 1 other = 1 len = 502 other = 1 binsiz = 39 y = logical 0 bins = Columns 1 through 29 494 8 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 40 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 504 other = 1 binsiz = 40 y = logical 0 bins = Columns 1 through 29 466 26 6 3 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 67 0 0 0 0 0 0 0 0 1 other = 1 len = 505 other = 1 binsiz = 67 y = logical 0 bins = Columns 1 through 29 476 12 5 1 4 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 53 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 502 other = 1 binsiz = 53 y = logical 0 bins = 385 101 8 1 3 0 0 1 0 1 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 0 0 0 1 other = 1 len = 504 other = 1 binsiz = 29 y = logical 0 bins = Columns 1 through 29 364 129 5 0 2 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 502 other = 1 binsiz = 44 y = logical 0 bins = Columns 1 through 29 490 3 1 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 36 0 0 0 0 1 1 1 other = 1 len = 501 other = 1 binsiz = 36 y = logical 0 bins = 296 164 19 10 1 1 2 1 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 2 other = 1 len = 501 other = 1 binsiz = 27 y = logical 0 bins = Columns 1 through 29 357 90 25 9 1 7 0 2 1 0 1 0 1 0 1 2 0 0 1 1 0 0 0 0 1 0 0 1 1 Columns 30 through 31 0 1 other = 1 len = 503 other = 1 binsiz = 31 y = logical 0

8   Pass
% Skewed (2), long faults = 0; isRandom_C = false; for i = 1 : 10 x = randi(1000) - 10 ./ rand(1, 500+randi(5)); isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 51 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 3 13 42 439 other = 1 len = 503 other = 1 binsiz = 51 y = logical 0 bins = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 56 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 3 79 414 other = 1 len = 503 other = 1 binsiz = 56 y = logical 0 bins = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 1 0 3 0 1 0 3 2 0 1 0 2 3 1 2 10 4 5 10 Columns 30 through 32 24 80 350 other = 1 len = 503 other = 1 binsiz = 32 y = logical 0 bins = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 Columns 30 through 34 1 2 7 21 467 other = 1 len = 502 other = 1 binsiz = 34 y = logical 0 bins = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 2 3 16 63 411 other = 1 len = 501 other = 1 binsiz = 55 y = logical 0 bins = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 44 0 0 0 0 0 0 0 0 1 1 1 3 4 32 459 other = 1 len = 502 other = 1 binsiz = 44 y = logical 0 bins = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 54 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 3 0 3 6 7 17 199 264 other = 1 len = 503 other = 1 binsiz = 54 y = logical 0 bins = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 Columns 30 through 35 1 4 4 8 32 451 other = 1 len = 505 other = 1 binsiz = 35 y = logical 0 bins = Columns 1 through 29 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 2 0 0 Columns 30 through 40 0 0 0 2 0 1 1 3 7 22 460 other = 1 len = 503 other = 1 binsiz = 40 y = logical 0 bins = 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 3 1 0 2 3 3 2 9 13 31 111 321 other = 1 len = 504 other = 1 binsiz = 27 y = logical 0

9   Pass
% Bimodal, long faults = 0; isRandom_C = false; for i = 1 : 10 x = [rand(1, 250+randi(5)), 999 + rand(1, 250+randi(5))]; isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = 252 0 0 0 255 other = 1 len = 507 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 252 0 0 0 255 other = 1 len = 507 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 251 0 0 0 255 other = 1 len = 506 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 253 0 0 0 254 other = 1 len = 507 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 251 0 0 0 251 other = 1 len = 502 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 253 0 0 0 253 other = 1 len = 506 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 251 0 0 0 251 other = 1 len = 502 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 255 0 0 0 255 other = 1 len = 510 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 252 0 0 0 254 other = 1 len = 506 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 255 0 0 0 252 other = 1 len = 507 other = 1 binsiz = 5 y = logical 0 y = logical 0

10   Fail
% 'Normal' (a.k.a. 'Gaussian'), long faults = 0; isRandom_C = false; for i = 1 : 10 x = 250 * randn(1, 500+randi(5)); isRandom = isItRandom(x); if ~isequal(isRandom, isRandom_C), faults = faults + 1; warning('*** CAUTION: %u faults recorded so far. ***', faults); end; assert(faults <= 2, 'Too many wrong assessments.'); end;

bins = 2 2 3 7 21 45 45 50 81 79 62 47 34 11 7 4 1 other = 1 len = 501 other = 1 binsiz = 17 [Warning: *** CAUTION: 1 faults recorded so far. ***] [> In ScoringEngineTestPoint10 (line 9) In solutionTest (line 23)] bins = 1 0 0 4 8 9 26 56 77 90 74 70 45 27 6 6 2 2 other = 1 len = 503 other = 1 binsiz = 18 [Warning: *** CAUTION: 2 faults recorded so far. ***] [> In ScoringEngineTestPoint10 (line 9) In solutionTest (line 23)] bins = 2 1 2 11 25 36 47 64 72 77 72 54 18 10 6 2 1 0 1 other = 1 len = 501 other = 1 binsiz = 19 [Warning: *** CAUTION: 3 faults recorded so far. ***] [> In ScoringEngineTestPoint10 (line 9) In solutionTest (line 23)]

Too many wrong assessments.