Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
% test for correct size
for iter = 1:10
vectorLength = randi([1 100]);
result = fcn(vectorLength);
assert(isequal([vectorLength, 1], size(result)));
end
|
2 | Pass |
% get large sample
vectorLength = 10000;
result = fcn(vectorLength);
% build empirical cumulative distribution function
xEmpirical = sort(result); % x-axis
yEmpirical = (1:vectorLength).' ./ vectorLength; % y-axis
% build theoretical cumulative distribution function
xTheoretical = xEmpirical; % x-axis
erfInput = sqrt(0.5) / pi * (xTheoretical - exp(1));
yTheoretical = 0.5*erf(erfInput) + 0.5; % y-axis
% compute statistics on diff between empirical and theoretical
errorList = abs(yEmpirical - yTheoretical);
errorMax = max(errorList);
errorSum = sum(errorList);
errorStd = std(errorList);
% if fcn is correct, this should pass at least 99.9% of the time
assert(errorMax < .02);
assert(errorSum > 10.1);
assert(errorStd > .00075);
|
3074 Solvers
Find all elements less than 0 or greater than 10 and replace them with NaN
13048 Solvers
2240 Solvers
Golomb's self-describing sequence (based on Euler 341)
106 Solvers
Polite numbers. N-th polite number.
128 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!