MATLAB: Resample with replacement – bootstrap Kolmogorov–Smirnov test

bootstrappingresample with replacementresampling techniques

Good afternoon,
I am trying to apply the bootstrap Kolmogorov–Smirnov test developed by Abadie (2002) to test if two series of results are from the same continuous distribution.
The first step of the methodology is the application of the ks test to the original series of results:
[ks_h,ks_p] = kstest2(results_1, results_50);
Then I need to resample n observations (in results_1 and in results_50) with replacement. I took a look at some Matlab built in functions but it seems to me that none of them do exactly what is proposed by Abadie (2002). The bootstrp function returns the result of some calculation (bootfun argument)made with the resampled series (and I just want the resampled series). The datasample function returns a subsample (and that is not what I need).
How can I resample n observations with replacement without using this kind of built in functions? Please find attached the paper with the described methodology.
Thanks in advance!

Best Answer

"How can I resample n observations with replacement without using this kind of built in functions?"
Those function can be useful for your needs but to resample your data with replacement all you need is randi().
nResamp = 1000; % number of resamples; use numel(results_1) to equate sample size.
results_1_resamp = results_1(randi(numel(results_1),1,nResamp));
results_50_resamp = results_50(randi(numel(results_50),1,nResamp));
*Assuming results_1 and _50 are vectors.