CCalclabhub

Work

Scaling a uniform draw into a range

The uniform fraction is multiplied by the width of the range and shifted up by the minimum. For integers the fractional part is dropped afterwards.

The Formula

value = min + u x (max - min)

The uniform fraction is multiplied by the width of the range and shifted up by the minimum. For integers the fractional part is dropped afterwards.

SymbolMeaning
uUniform draw
minMinimum
maxMaximum
vDrawn value

What Each Symbol Means

ufraction

Uniform draw

A value in [0, 1) from the generator.

minvalue

Minimum

The smallest value the draw may return.

maxvalue

Maximum

The largest value the draw may return.

vvalue

Drawn value

The result shifted into the range.

See It Worked With Real Numbers

A formula on its own does not tell you which number goes where. The how to generate random numbers page applies this equation to a concrete case, shows every intermediate step, and names the mistakes that produce a wrong answer even when the algebra is right.

Where This Formula Appears

This equation is the working core of How To Generate Random Numbers, filed under Everyday Life. Every number the guide produces comes from substituting into this one line.