C# Класс RandomOps.RanUInt32

Pseudo-Random Number Generator (PRNG) base-class for a generator of UInt32 integers.
It is somewhat tricky to implement Index() using integer-operations and get the rounding right for all cases, so we reuse the base-class implementation which indirectly uses Uniform().
Наследование: Random
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Bool ( ) : bool

Draw a random boolean with equal probability of drawing true or false. Thread-safe if Rand() is thread-safe.

Byte ( ) : byte

Draw a random and uniform byte. Thread-safe if Rand() is thread-safe.

The least significant bits are not that statistically random, hence we must use the most significant bits by a bit-shift.

RanUInt32 ( ) : System

Constructs the PRNG-object.

Rand ( ) : UInt32

Draw a random number in inclusive range {0, .., RandMax}

Uniform ( ) : double

Draw a uniform random number in the exclusive range (0,1). Thread-safe if Rand() is thread-safe.

Assumes that Rand() is in {0, .., RandMax}.

Защищенные методы

Метод Описание
Seed ( ) : void

Seed with the time of day.

Seed ( UInt32 seed ) : void

Seed with an integer.

Описание методов

Bool() публичный Метод

Draw a random boolean with equal probability of drawing true or false. Thread-safe if Rand() is thread-safe.
public Bool ( ) : bool
Результат bool

Byte() публичный Метод

Draw a random and uniform byte. Thread-safe if Rand() is thread-safe.
The least significant bits are not that statistically random, hence we must use the most significant bits by a bit-shift.
public Byte ( ) : byte
Результат byte

RanUInt32() публичный Метод

Constructs the PRNG-object.
public RanUInt32 ( ) : System
Результат System

Rand() публичный абстрактный Метод

Draw a random number in inclusive range {0, .., RandMax}
public abstract Rand ( ) : UInt32
Результат System.UInt32

Seed() защищенный Метод

Seed with the time of day.
protected Seed ( ) : void
Результат void

Seed() защищенный Метод

Seed with an integer.
protected Seed ( UInt32 seed ) : void
seed System.UInt32
Результат void

Uniform() публичный Метод

Draw a uniform random number in the exclusive range (0,1). Thread-safe if Rand() is thread-safe.
Assumes that Rand() is in {0, .., RandMax}.
public Uniform ( ) : double
Результат double