Cody

Solution 2007089

Submitted on 7 Nov 2019 by kranthi kumar
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
rnd = sort(rand(randi([10,20]),1)); prob = vertcat(rnd(1,:),diff(rnd,1,1),1-rnd(end,:)); sz = [1 1e5;1e5 1;1e3 1e2;randi([100 200], 100, 2)]; sz = sz(randi(size(sz,1)),:); x = rndsampling(sz(1),sz(2),prob); prob_est = histcounts(x,1:numel(prob)+1,'Normalization','probability').'; err = mean(abs(prob_est - prob)) assert(err < 0.005 && isequal(size(x),sz) && all(~isnan(x(:))));

err = 2.1324e-05