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);
% built empirical cumulative distribution function
xEmpirical = 0:10; % x-axis
counts = accumarray(result+1, 1);
density = counts ./ sum(counts);
yEmpirical = cumsum(density); % y-axis
% build theoretical cumulative distribution function
xTheoretical = xEmpirical; % x-axis
for k = xTheoretical
yTheoretical(k+1, 1) = betainc(exp(-1), 10-k, k+1); % y-axis
end
% 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 < .018);
assert(errorSum > .0045);
assert(errorStd > .0004);
|
1365 Solvers
101 Solvers
579 Solvers
404 Solvers
Flip the vector from right to left
2666 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!