I'd like to generate an array of Random numbers with defined Min, Max, Mean and Stdev with given number of elements and error level. Is there such a library in C, C++, PHP or Python to do so? Please kindly advise. Thanks!
views:
217answers:
4The Boost C++ random number library may do some of what you want, certainly you can with some distributions select the modal value of the distribution. That's all I've needed in my own code, so I've never investigated further. The library doesn't generate arrays - you would typically use a C++ std::vector
to contain the results of random number generation.
If you want to use python, then I suggest that you use numpy.
http://docs.scipy.org/doc/numpy/reference/routines.random.html
You can probably find many distributions that fit your needs, but maybe you can sample from a beta distribution and rescale the values to fit your needs. Your code will end up looking like this
a1, a2 = ....
temp_array = numpy.random.beta(a1, a2, array_size)
answer = temp_array*(max_value-min_value) + min_value
If you choose this aproach then you need to do a bit of work to find formulas for a1 and a2.