Extended Random Sample with procedure

Not template, as it shoul be, but...