jeudi 25 avril 2019

How to generate a uniformly distributed random double in C using libsodium in range [-a,a]?

The libsodium library has a function

uint32_t randombytes_uniform(const uint32_t upper_bound);

but obviously this returns an unsigned integer. Can I somehow use this to generate a uniformly distributed random double in range [-a,a] where a is also a double given by the user ? I am especially focused on the result being uniformly distributed/unbiased, so that is why I would like to use the libsodium library.




Aucun commentaire:

Enregistrer un commentaire