public static InputSample[] Resample(int num_bootstraps, InputSample orig_vals, Random rng)
{
// the resampled values go here
var ss = new InputSample[num_bootstraps];
// sample with replacement to get i bootstrapped samples
for (var i = 0; i < num_bootstraps; i++)
{
var s = new InputSample(orig_vals.Rows(), orig_vals.Columns());
// make a vector of index counters
var inc_count = new int[orig_vals.Length()];
// randomly sample j values, with replacement
for (var j = 0; j < orig_vals.Length(); j++)
{
// randomly select a value from the original values
int input_idx = rng.Next(0, orig_vals.Length());
inc_count[input_idx] += 1;
if (input_idx >= orig_vals.Length())
{
throw new Exception("input_idx >= orig_vals.Length()");
}
string value = orig_vals.GetInput(input_idx);
s.Add(value);
}
// indicate which indices are excluded
s.SetIncludes(inc_count);
// add the new InputSample to the output array
ss[i] = s;
}
return(ss);
}