Make Random Numbers Tend / Average to a Specific Value
问题 How can I for example generate a list of random numbers between 0 and 1, but have them avarage at 0.8? I have written this little script in C++ that'll tell you what numbers got output. This question is not really C++ related though. #include <iostream> #include <random> #include <time.h> int main(int argCount, char** argVector) { std::cout << "Generating Randoms" << std::endl; float avarage = 0.F; srand(rand() + (int) time(NULL)); float ceiling = 0; float bottom = 1; for(unsigned int i = 0;