| Random |
|
typedict |
| |
A
Random
is a pseudo-random number generator object.
It can generate standard pseudo-random numbers
and also the so-called
cryptographically strong,
or
secure,
random numbers.
Yoix programs interact with these pseudo-random number generators
by reading, writing or executing the following
Random
fields:
| binary |
A read-only
int
that provides, each time it is read, a pseudo-random binary value, namely zero or one, generated
according to a uniform distribution.
| | bytes(int size) |
A
Builtin
that returns an
Array
of the specified
size
that contains
int
values uniformly distributed in the range
0
to
255.
| | double |
A read-only
double
that provides, each time it is read, a pseudo-random value in the range
0.0
to
1.0
and generated according to a uniform distribution.
| | gaussian |
A read-only
double
that provides, each time it is read, a pseudo-random value
generated according to a gaussian distribution with mean
0.0
and standard deviation of
1.0.
| | int |
A read-only
int
that provides, each time it is read, a pseudo-random value in the range
yoix.math.MIN_INT
to
yoix.math.MAX_INT
and generated according to a uniform distribution.
| | provider |
When the generator is cryptographically strong, this field provides a read-only
Dictionary
value that gives information about the provider for algorithm used by
the generator.
| | range(int limit) |
A
Builtin
that returns an
int
value uniformly distributed in the range starting with
0
and extending up to, but not including, the supplied
limit
value, which must be greater than zero.
| | secure |
An
int
that is zero when the numbers generated by this object are standard pseudo-random
numbers and non-zero when the generated numbers are cryptographically strong
pseudo-random numbers.
Reading gives the type of the current generator and writing
immediately sets the generator to the new type.
| | seed |
The seed used for this pseudo-random number generator.
When
secure
is zero, then the seed is a
double,
but when
secure
is non-zero, then the seed is an
Array
of
int
values.
Reading the value gives the initial seed for this genertor, writing
the value resets the generator using the new seed.
Unlike a standard generator, resetting the seed for a
cryptographically strong generator does not cause the same sequence of
pseudo-random numbers to be re-generated.
For the standard case, the default seed is equivalent to seeding with
the current time as obtained with
,BR yoix.system.time() .
| | specification |
This field is only useful for initializing a cryptographically strong
pseudo-random number generator.
When writing, it can be either a
String
giving the algorithm to be used by the generator, or it can be a
Dictionary
containing
String-valued
name
and
provider
fields to specificy the name and provider of the generator
algorithm.
Reading returns the previously set value, if any.
|
Several permanent fields have not been documented and should not be
used in Yoix applications.
| |
| Example: |
The program,
import yoix.*.*;
creates a
| | |
| See Also: |
Cipher,
Key,
random
|
|
Yoix is a registered trademark of AT&T Inc.
|