How to generate a random number

using Probability Distribution? My assignment deals with CPU-Scheduling and for some purposes I am supposed to come up with a random number between 0 and 40 using Probability Distribution. I googled it but it turns out that the probability distribution would be a number between 0 and 1. What am I missing here?
If you have random number in the range [0.0,1.0) (as a floating point number)
you can generate a random number in the range [a,b) by applying the following algorithm:
1
2
3
4
5
const float a = 0.0;
const float b = 40.0;

float rand_0_1 = getRand();
float rand_a_b = a + (b-a) * rand_0_1;
Probably stuff like this: http://en.wikipedia.org/wiki/Normal_distribution

Random events are not always equally distributed across a given interval. Sometimes, some values are more likely than others.

Probability Distribution
http://en.wikipedia.org/wiki/Probability_distribution
Before you plan to create your own random number generator, maybe take a look at this:

http://www.boost.org/doc/libs/1_47_0/doc/html/boost_random.html
Topic archived. No new replies allowed.