-
4 Comments
true randomness is a bit involved to test (particularly without the stats toolbox), plus the sum constrain adds some additional complexity to the randomness of the resulting values (see for example this Cody problem: http://www.mathworks.com/matlabcentral/cody/problems/331-compute-area-from-fixed-sum-cumulative-probability). In any way, the simplest solution to discourage this sort of extremely-non-random solutions would probably be running your current testsuite twice (with identical inputs) and then checking that the returned vectors are different...
Another possibility, would be to test that there is no repetition in the returned values, which can easily be tested with: assert(all(diff(sort(sum_array))));
you're right guillaume, i apppreciate that.
Suggested Problems
-
4512 Solvers
-
Back to basics 23 - Triangular matrix
1037 Solvers
-
190 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
11984 Solvers
-
120 Solvers
More from this Author6
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!