mercredi 26 avril 2017

How to create a custom random distribution function?

Normally I generate values using the built in random functions, but now I need to create a random distribution of the form

f(x) = k*log(x) + m

Is it possible to define a custom random distribution function? Ideally I would like it to work how the current built-in distributions do:

int main() 
{
    std::mt19937 generator;

    std::uniform_real_distribution<> dist(0.0, 1.0);
    my_distribution my_dist(0.0, 10.0); // Distribution using f(x)

    double uni_val = dist(generator);
    double log_val = my_dist(generator);
}

Aucun commentaire:

Enregistrer un commentaire