I want to define a specific probability density function (pdf) for n numbers at C++ and then pick some of them later in my code.
my pdf is : P (x) = (1/logn) * f(x)^(-2)
f(x) has a deterministic number that is already determined for each x earlier in my code.
I prefer to use standard library function, since I should use my program in a computer cluster that using additional libraries such as boost more likely produces further issues in that cluster.
my initial code that I have found is:
for(int x=1;x<n+1;x++){
// I calculate all f(x) and therefore P(x) here
}
std::default_random_engine generator;
std::discrete_distribution<int> distribution { .. not sure how to use P(x)s here .. };
int prob[n]={};
for (int i=0; i<n; ++i) {
int number = distribution(generator);
++prob[number];
}
Many thanks in advance.