Cody

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

Solution 1945948

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   Fail
% 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 = 6 10 11 3 other = 1 len = 30 other = 1 binsiz = 4 bins = 7 5 14 1 other = 1 len = 27 other = 1 binsiz = 4 y = logical 0 [Warning: *** CAUTION: 1 faults recorded so far. ***] [> In ScoringEngineTestPoint1 (line 9) In solutionTest (line 5)] bins = 8 5 9 3 other = 1 len = 25 other = 1 binsiz = 4 bins = 10 12 2 3 other = 1 len = 27 other = 1 binsiz = 4 y = logical 0 [Warning: *** CAUTION: 2 faults recorded so far. ***] [> In ScoringEngineTestPoint1 (line 9) In solutionTest (line 5)] bins = 11 11 6 2 other = 1 len = 30 other = 1 binsiz = 4 bins = 5 11 4 4 other = 1 len = 24 other = 1 binsiz = 4 y = logical 0 [Warning: *** CAUTION: 3 faults recorded so far. ***] [> In ScoringEngineTestPoint1 (line 9) In solutionTest (line 5)]

Too many wrong assessments.

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 11 other = 1 len = 24 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 14 13 other = 1 len = 27 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 14 13 other = 1 len = 27 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 13 11 other = 1 len = 24 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 = 11 15 other = 1 len = 26 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 15 12 other = 1 len = 27 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 15 12 other = 1 len = 27 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 13 11 other = 1 len = 24 other = 1 binsiz = 2 y = logical 0 y = logical 0 bins = 15 11 other = 1 len = 26 other = 1 binsiz = 2 y = logical 0 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 = 5 24 24 13 21 14 other = 1 len = 101 other = 1 binsiz = 6 bins = 4 22 20 17 26 12 other = 1 len = 101 other = 1 binsiz = 6 bins = 22 16 23 22 23 2 other = 1 len = 108 other = 1 binsiz = 6 bins = 15 12 23 20 29 6 other = 1 len = 105 other = 1 binsiz = 6 bins = 5 26 18 20 22 18 other = 1 len = 109 other = 1 binsiz = 6 bins = 15 17 26 16 19 9 other = 1 len = 102 other = 1 binsiz = 6 bins = 6 31 19 19 19 10 other = 1 len = 104 other = 1 binsiz = 6 bins = 7 25 25 21 19 13 other = 1 len = 110 other = 1 binsiz = 6 bins = 5 21 20 16 27 12 other = 1 len = 101 other = 1 binsiz = 6 bins = 7 30 21 22 16 13 other = 1 len = 109 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 = 53 0 0 54 other = 1 len = 107 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 55 0 0 55 other = 1 len = 110 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 52 0 0 55 other = 1 len = 107 other = 1 binsiz = 4 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 52 other = 1 len = 106 other = 1 binsiz = 4 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 54 other = 1 len = 105 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 54 0 0 52 other = 1 len = 106 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 51 0 0 55 other = 1 len = 106 other = 1 binsiz = 4 y = logical 0 y = logical 0 bins = 55 0 0 0 54 other = 1 len = 109 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 = 96 4 2 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 103 other = 1 binsiz = 14 y = logical 0 bins = 101 2 0 0 0 0 2 0 0 0 0 0 0 1 other = 1 len = 106 other = 1 binsiz = 14 y = logical 0 bins = 97 3 0 0 1 1 0 0 0 0 0 1 other = 1 len = 103 other = 1 binsiz = 12 y = logical 0 bins = 84 8 2 3 1 0 1 1 0 0 0 0 0 0 1 other = 1 len = 101 other = 1 binsiz = 15 y = logical 0 bins = 90 7 4 0 0 0 0 1 1 0 0 0 0 0 0 0 1 other = 1 len = 104 other = 1 binsiz = 17 y = logical 0 bins = 92 8 3 2 0 1 0 0 0 1 other = 1 len = 107 other = 1 binsiz = 10 y = logical 0 bins = 102 0 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 103 other = 1 binsiz = 13 y = logical 0 bins = 97 3 1 0 0 0 0 0 0 0 0 0 1 other = 1 len = 102 other = 1 binsiz = 13 y = logical 0 bins = 82 10 4 5 0 0 0 0 1 other = 1 len = 102 other = 1 binsiz = 9 y = logical 0 bins = 97 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 104 other = 1 binsiz = 20 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 = 53 43 57 53 57 50 43 47 52 54 other = 1 len = 509 other = 1 binsiz = 10 bins = 54 45 56 34 53 56 57 49 54 44 other = 1 len = 502 other = 1 binsiz = 10 bins = 45 52 56 47 62 51 40 44 60 51 other = 1 len = 508 other = 1 binsiz = 10 bins = 56 56 60 52 40 38 52 48 49 59 other = 1 len = 510 other = 1 binsiz = 10 bins = 53 42 53 47 44 49 51 55 41 72 other = 1 len = 507 other = 1 binsiz = 10 bins = 50 63 47 58 51 51 47 50 42 48 other = 1 len = 507 other = 1 binsiz = 10 bins = 48 57 46 46 64 48 52 65 40 44 other = 1 len = 510 other = 1 binsiz = 10 bins = 36 47 47 41 49 60 58 56 49 63 other = 1 len = 506 other = 1 binsiz = 10 bins = 53 48 49 42 59 59 48 55 39 51 other = 1 len = 503 other = 1 binsiz = 10 bins = 47 56 41 48 54 49 62 41 58 52 other = 1 len = 508 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 30 482 14 3 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 Columns 31 through 60 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 0 Columns 61 through 69 0 0 0 0 0 0 0 0 1 other = 1 len = 503 other = 1 binsiz = 69 y = logical 0 bins = Columns 1 through 30 456 23 9 2 2 5 0 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 60 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 0 Columns 61 through 67 0 0 0 0 0 0 1 other = 1 len = 502 other = 1 binsiz = 67 y = logical 0 bins = 459 21 6 5 2 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 other = 1 len = 504 other = 1 binsiz = 20 y = logical 0 bins = Columns 1 through 30 34 377 42 18 11 3 4 0 3 0 2 0 0 1 1 1 1 2 0 0 0 0 0 1 0 0 0 0 0 0 Columns 31 through 32 0 1 other = 1 len = 502 other = 1 binsiz = 32 y = logical 0 bins = Columns 1 through 30 473 21 5 1 0 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 Columns 31 through 44 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 30 487 8 4 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 52 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 = 52 y = logical 0 bins = Columns 1 through 30 474 18 3 1 1 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 501 other = 1 binsiz = 46 y = logical 0 bins = Columns 1 through 30 412 40 19 4 8 4 4 3 1 0 0 1 0 0 0 2 0 3 2 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 41 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 504 other = 1 binsiz = 41 y = logical 0 bins = Columns 1 through 30 428 43 14 5 5 2 2 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 Columns 31 through 49 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 = 49 y = logical 0 bins = Columns 1 through 30 404 64 17 7 0 1 2 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 55 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 other = 1 len = 502 other = 1 binsiz = 55 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 30 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 0 Columns 31 through 43 0 0 0 0 0 1 1 1 1 3 7 46 444 other = 1 len = 505 other = 1 binsiz = 43 y = logical 0 bins = Columns 1 through 30 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 1 0 0 0 0 Columns 31 through 42 0 0 0 0 1 4 1 4 3 12 39 437 other = 1 len = 503 other = 1 binsiz = 42 y = logical 0 bins = Columns 1 through 30 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 0 Columns 31 through 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 Columns 61 through 66 0 1 0 1 5 495 other = 1 len = 505 other = 1 binsiz = 66 y = logical 0 bins = Columns 1 through 30 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 Columns 31 through 46 0 0 0 1 0 2 1 1 1 0 0 5 10 15 28 434 other = 1 len = 501 other = 1 binsiz = 46 y = logical 0 bins = Columns 1 through 30 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 2 0 1 1 3 1 Columns 31 through 33 15 48 427 other = 1 len = 501 other = 1 binsiz = 33 y = logical 0 bins = Columns 1 through 30 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 2 1 Columns 31 through 36 3 6 16 19 93 357 other = 1 len = 503 other = 1 binsiz = 36 y = logical 0 bins = Columns 1 through 30 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 48 0 0 0 0 0 0 0 1 0 0 1 0 2 0 2 4 27 463 other = 1 len = 502 other = 1 binsiz = 48 y = logical 0 bins = Columns 1 through 30 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 2 0 0 1 1 0 0 2 2 5 3 4 14 Columns 31 through 33 15 66 384 other = 1 len = 501 other = 1 binsiz = 33 y = logical 0 bins = Columns 1 through 30 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 45 0 0 0 0 0 0 0 0 1 1 0 2 14 117 367 other = 1 len = 504 other = 1 binsiz = 45 y = logical 0 bins = Columns 1 through 30 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 0 Columns 31 through 40 1 1 0 1 1 5 7 24 248 211 other = 1 len = 505 other = 1 binsiz = 40 y = logical 0 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 = 255 0 0 0 253 other = 1 len = 508 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 255 0 0 0 251 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 = 254 0 0 0 255 other = 1 len = 509 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 254 0 0 0 255 other = 1 len = 509 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 253 0 0 0 252 other = 1 len = 505 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 251 0 0 0 254 other = 1 len = 505 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 bins = 255 0 0 0 253 other = 1 len = 508 other = 1 binsiz = 5 y = logical 0 y = logical 0 bins = 254 0 0 0 251 other = 1 len = 505 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 = 1 5 6 10 18 38 46 60 59 79 73 44 40 13 8 3 other = 1 len = 503 other = 1 binsiz = 16 [Warning: *** CAUTION: 1 faults recorded so far. ***] [> In ScoringEngineTestPoint10 (line 9) In solutionTest (line 23)] bins = 1 4 6 18 34 43 78 81 85 65 31 30 20 5 3 1 other = 1 len = 505 other = 1 binsiz = 16 [Warning: *** CAUTION: 2 faults recorded so far. ***] [> In ScoringEngineTestPoint10 (line 9) In solutionTest (line 23)] bins = 2 7 23 34 56 66 77 81 63 46 19 17 8 2 1 1 other = 1 len = 503 other = 1 binsiz = 16 [Warning: *** CAUTION: 3 faults recorded so far. ***] [> In ScoringEngineTestPoint10 (line 9) In solutionTest (line 23)]

Too many wrong assessments.