I have a data vector A of length 1 Million (0 to 1 Million). From A, I want to create the vector B (whose length is lets say just 10% of A) containing indexes of A. Those indexes are randomly taken sample indexes from A. I tried using srand() and random_shuffle, is this a good way to extracting samples for very huge vectors? Can anyone plz suggest me.
std::vector <int> samplingIndex;
for (int i = 0; i < 1000000; ++i) { samplingIndex.push_back(i); }
std::srand(50);
std::random_shuffle(samplingIndex.begin(), samplingIndex.end());
After this I take the first 10% indexes from samplingIndex to make B.