Cody

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

Solution 1945954

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;

y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 0 [Warning: *** CAUTION: 1 faults recorded so far. ***] [> In ScoringEngineTestPoint1 (line 9) In solutionTest (line 5)]

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;

y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 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;

y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1

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;

y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 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;

y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 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;

y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1 y = logical 1

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;

y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 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;

y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 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;

y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 y = logical 0 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;

y = logical 1 [Warning: *** CAUTION: 1 faults recorded so far. ***] [> In ScoringEngineTestPoint10 (line 9) In solutionTest (line 23)] y = logical 1 [Warning: *** CAUTION: 2 faults recorded so far. ***] [> In ScoringEngineTestPoint10 (line 9) In solutionTest (line 23)] y = logical 1 [Warning: *** CAUTION: 3 faults recorded so far. ***] [> In ScoringEngineTestPoint10 (line 9) In solutionTest (line 23)]

Too many wrong assessments.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!