#include <iostream>
#include <random>
#include <vector>
int main()
{
double lower_limit = -15000;
double upper_limit = 15000;
double range = upper_limit - lower_limit ;
std::mt19937 rng((std::random_device())());
std::uniform_real_distribution<double> dist(lower_limit, upper_limit);
double highest_result = lower_limit -1;
double lowest_result = upper_limit + 1;
const unsigned samples = 1000000;
std::vector<unsigned> block_count(5);
for (unsigned i = 0; i < samples; ++i)
{
double value = dist(rng);
if (value < lowest_result)
lowest_result = value;
if (value > highest_result)
highest_result = value;
for (unsigned i = 0; i < 5; ++i)
{
if (value - lower_limit < (range / 5.0) * (i + 1))
{
++block_count[i];
break;
}
}
}
std::cout << "range limit, " << lower_limit << " to " << upper_limit << '\n';
std::cout << "highest result, " << highest_result << '\n';
std::cout << "lowest result, " << lowest_result << '\n';
std::cout << "breakdown of result range by fifths for one run through\n";
for (unsigned i = 0; i < 5; ++i)
std::cout << "to " << ((i + 1) / 5.0)*100.0 << "%: " << block_count[i] << " results\n";
}