Here's a
generalized description of the idea ... pretty much applicable to any language (including this one).
A "PRNG = Pseudo-Random Number Generator" is an algorithm that produces a "random" series of values – that is to say, "very unpredictable." (For statistics work, "an acceptably un-biased source of numbers for use in drawing samples from a population, and with certain favorable statistical characteristics.") The term,
"pseudo," refers to the fact that the actual sequence, necessarily, "isn't 'random' at all."
Each new value that is produced is mathematically based upon a so-called
seed, and each iteration calculates a new seed.
- A fundamental property of these algorithms – very useful and important for statistical work – is that, "given an identical starting seed, the PRNG will always produce the same 'random' sequence." So, if you capture the seed-value before starting to produce a 'random' sequence, you can always re-create that exact same sequence in the future. (Very handy if the sequence is to be very long ...)
When a typical program starts, it must (somehow) produce a new "initial seed" for its PRNG. It wants this value to be "fairly unpredictable." There are various ways to do this – the exact value of the computer's clock at this precise instant, or some other source of
[pseudo-]randomness such as
/dev/urandom. Most importantly, if the program is run twice in a row, its "initial seed" value each time should
(by default ...) be different, and "unpredictable." I surmise that this is what the first few statements that you have quoted are actually doing.
(And yet, if you do want to know what the current seed-value is ... and/or to set the seed to a particular value ... facilities exist to allow you to do that, for the statistical purposes aforementioned.)
There are various ways to use the
output of a PRNG. In your program, it appears that it is being set to produce values in the inclusive range from "1.0" to "100.0," and that they are to be
"real numbers (vs. integers). This sort of capability is entirely typical. But I admit to being unfamiliar with the particular language that you are referring-to here.
Run-of-the-mill PRNGs are fine for computer games, and they are specifically designed for use in statistics, but they are
n-o-t(!) suitable for cryptographic work. An entirely different class of
[public ...] algorithms are used for
that very-special mathematical purpose.
Anyway – "hope this helps to set the stage."