Just to be clear before I ask, I am only asking out of curiosity. Lucky for me I am not a cat.
I have created a quick sort function for a University project, and thought that maybe (rather than just bashing away at the keyboard for a while) I could test it with some lists of integers generated randomly.
std::vector<int> unsorted_list;
std::random_device ran_dev; // Initialise a new random device
std::uniform_int_distribution<> uni_dist(1, 100); // Create Uniform Distribution
for (int i = 0; i < 5; i++) {
unsorted_list.push_back(uni_dist(ran_dev));
}
Can I fully rely on this implementation to produce random numbers that do always appear to actually be random (evenly distributed)?
You might think I'm being silly... Clearly the class states that it is a uniform distribution, as in, it's not possible to be non-uniform... But are any of these outputs even possible? And if so, how likely?
(1, 1, 1, 1, 1)
(1, 2, 3, 4, 5)
(2, 4, 6, 8, 10)
I suppose the last output is more likely than the first or second (especially when using bounds of 0 to 100), but my curiosity still has me.
Am I being particularly foolish? I've never been very good at maths, so, although I'm beginning to understand symbols and terminology, I still look at some explanations and simply "glaze over", so my googling so far hasn't been helpful.
Aucun commentaire:
Enregistrer un commentaire