bool done = false;
int myrand;
while (!done) {
- myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+ myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
if (subset.count(names[myrand]) == 0) {
}
}
}else {
+
//randomly select a subset of those names to include in the subsample
for (int j = 0; j < size; j++) {
bool done = false;
int myrand;
while (!done) {
- myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+ myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
if (subset.count(names[myrand]) == 0) {
if (m->control_pressed) { delete order; return 0; }
//get random number to sample from order between 0 and thisSize-1.
- int myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+ int myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
int bin = order->get(myrand);
bool done = false;
int myrand;
while (!done) {
- myrand = (int)((float)(rand()) / (RAND_MAX / (names.size()-1) + 1));
+ myrand = int((float)(names.size()) * (float)(rand()) / ((float)RAND_MAX+1.0));
if (subset.count(names[myrand]) == 0) { //you are not already added
if (groupMap->getGroup(names[myrand]) == Groups[i]) { subset.insert(names[myrand]); break; }
bool done = false;
int myrand;
while (!done) {
- myrand = (int)((float)(rand()) / (RAND_MAX / (names.size()-1) + 1));
+ myrand = int((float)(names.size()) * (float)(rand()) / ((float)RAND_MAX+1.0));
if (subset.count(names[myrand]) == 0) { subset.insert(names[myrand]); break; }
}
if (m->control_pressed) { delete order; return 0; }
//get random number to sample from order between 0 and thisSize-1.
- int myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+ int myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
int bin = order->get(myrand);
if (m->control_pressed) { delete order; return 0; }
//get random number to sample from order between 0 and thisSize-1.
- int myrand = (int)((float)(rand()) / (RAND_MAX / (thisSize-1) + 1));
+ int myrand = int((float)(thisSize) * (float)(rand()) / ((float)RAND_MAX+1.0));
int bin = order->get(myrand);