Commit ea60f622 authored by Davis King's avatar Davis King

Fixed a bug in randomize_samples(). It forced each element of the input arrays

to move to a new position but was random amongst all permutations with such
moves.  However, this isn't really fully random so this function has been fixed
so it does exactly what the spec says it should.
parent 6d32e8c8
......@@ -954,11 +954,8 @@ namespace dlib
long n = t.size()-1;
while (n > 0)
{
// put a random integer into idx
unsigned long idx = r.get_random_32bit_number();
// make idx be less than n
idx %= n;
// pick a random index to swap into t[n]
const unsigned long idx = r.get_random_32bit_number()%(n+1);
// swap our randomly selected index into the n position
exchange(t(idx), t(n));
......@@ -996,11 +993,8 @@ namespace dlib
long n = t.size()-1;
while (n > 0)
{
// put a random integer into idx
unsigned long idx = r.get_random_32bit_number();
// make idx be less than n
idx %= n;
// pick a random index to swap into t[n]
const unsigned long idx = r.get_random_32bit_number()%(n+1);
// swap our randomly selected index into the n position
exchange(t[idx], t[n]);
......@@ -1055,11 +1049,8 @@ namespace dlib
long n = t.size()-1;
while (n > 0)
{
// put a random integer into idx
unsigned long idx = r.get_random_32bit_number();
// make idx be less than n
idx %= n;
// pick a random index to swap into t[n]
const unsigned long idx = r.get_random_32bit_number()%(n+1);
// swap our randomly selected index into the n position
exchange(t(idx), t(n));
......@@ -1093,11 +1084,8 @@ namespace dlib
long n = t.size()-1;
while (n > 0)
{
// put a random integer into idx
unsigned long idx = r.get_random_32bit_number();
// make idx be less than n
idx %= n;
// pick a random index to swap into t[n]
const unsigned long idx = r.get_random_32bit_number()%(n+1);
// swap our randomly selected index into the n position
exchange(t[idx], t[n]);
......@@ -1144,11 +1132,8 @@ namespace dlib
long n = t.size()-1;
while (n > 0)
{
// put a random integer into idx
unsigned long idx = r.get_random_32bit_number();
// make idx be less than n
idx %= n;
// pick a random index to swap into t[n]
const unsigned long idx = r.get_random_32bit_number()%(n+1);
// swap our randomly selected index into the n position
exchange(t(idx), t(n));
......@@ -1171,11 +1156,8 @@ namespace dlib
long n = t.size()-1;
while (n > 0)
{
// put a random integer into idx
unsigned long idx = r.get_random_32bit_number();
// make idx be less than n
idx %= n;
// pick a random index to swap into t[n]
const unsigned long idx = r.get_random_32bit_number()%(n+1);
// swap our randomly selected index into the n position
exchange(t[idx], t[n]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment