-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandomSampling.m
37 lines (27 loc) · 864 Bytes
/
randomSampling.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [pdf] = randomSampling(error_all,NUM_RUNS,NUM_SAMPLES,MAX_ERROR)
% RANDOMSAMPLING is a function that randomly samples a given data structure
% with all the errors computed for a method, generating the distribution of
% them in a histogram of 100 bins (for now hardcoded.
%
% Usage: to use within queryRandomisation/queryRandomisationDense
%
% Author: Jose M. Rivera-Rubio (2013).
%
% Initial version: April, 2014
% Last Modified: Otober, 2015
Nbins = 100;
bins = linspace(0,MAX_ERROR,Nbins);
pdf = [];
for r = 1:NUM_RUNS
imax = length(error_all);
sampled_error = zeros(NUM_SAMPLES,1);
for i = 1:NUM_SAMPLES
sam = randi(imax,1);
sampled_error(i) = error_all(sam);
end
%% Histograms and PDF and CDF
[h,xc] = hist(sampled_error,bins);
pdf(r,:) = h/sum(h);
% plot(pdf)
end % end number of runs
end