#include <iostream>
#include <map>
#include <random>
#include <iterator>
#include <ctime>
int main()
{
//    std::random_device rd; // no access to /dev/urandom on ideone
//    std::mt19937 gen(rd()); 
    std::mt19937 gen(std::time(NULL));
    double weights[] =
            {0, // do not generate the number 0
             1, // number 1 at base probability
             2, // number 2 twice as often
             0.2, // number 3 at 1/5th probability
             0.2, // number 4 at 1/5th probability
             1, 1, 1, 1, 1, 1}; // 5..10 at base probability

//     std::discrete_distribution<> d(std::begin(weights), std::end(weights)); // ideone's compiler is outdated
     std::discrete_distribution<> d(weights, weights + sizeof weights/sizeof weights[0]);

    std::map<int, int> m;
    for(int n=0; n<10000; ++n) {
        ++m[d(gen)];
    }
//    for(auto p : m) { // ideone's compiler is outdated
    for(auto i = m.begin(); i!=m.end(); ++i) {
//        std::cout << p.first << " generated " << p.second << " times\n";
        std::cout << i->first << " generated " << i->second << " times\n";
    }
}