Package | com.yworks.bridge.util |
Class | public class Random |
Inheritance | Random YObject Object |
Subclasses | YRandom |
Based on a fast XOR-Shift PRNG by Marsaglia, George. (2003). Xorshift RNGs. http://www.jstatsoft.org/v08/i14/xorshift.pdf
Property | Defined By | ||
---|---|---|---|
seed : int [write-only]
Sets an int value as seed. | Random |
Method | Defined By | ||
---|---|---|---|
Random(init:Boolean = true)
Construct a random generator with the current time of day in milliseconds as the initial state. | Random | ||
equals(o:Object):Boolean | YObject | ||
getClass():Class [override] | Random | ||
hashCode():int | YObject | ||
[static]
Construct a random generator with the current time of day in milliseconds
as the initial state. | Random | ||
[static]
Construct a random generator with the given seed as the initial state. | Random | ||
nextBoolean():Boolean
Answers the next pseudo-random, uniformly distributed boolean value generated by this generator. | Random | ||
nextBytes(buf:Vector.<int>):void
Modifies the byte array by a random sequence of bytes generated by this random number generator. | Random | ||
nextDouble():Number
Generates a normally distributed random double number between 0.0 inclusively and 1.0 exclusively. | Random | ||
nextFloat():Number
Generates a normally distributed random float number between 0.0 inclusively and 1.0 exclusively. | Random | ||
nextGaussian():Number
Returns a pseudo-randomly generated, normally distributed double value with mean 0.0 and a standard deviation value of 1.0. | Random | ||
nextInt():int
Generates a uniformly distributed 32-bit int value from the this random number sequence. | Random | ||
nextInt2(n:int):int
Returns a new pseudo-random integer value which is uniformly distributed between 0 (inclusively) and n (exclusively). | Random | ||
Generates a uniformly distributed 64-bit int value from the this random
number sequence. | Random |
Method | Defined By | ||
---|---|---|---|
initRandom1():void
Initializes this object. | Random | ||
initRandom2(seed:LongImpl):void
Initializes this object. | Random | ||
next(bits:int):int
Returns a pseudo-random uniformly distributed int value of the number of bits specified by the argument bits. | Random |
seed | property |
seed:int
[write-only] Sets an int value as seed.
public function set seed(value:int):void
See also
Random | () | Constructor |
public function Random(init:Boolean = true)
Construct a random generator with the current time of day in milliseconds as the initial state.
Parametersinit:Boolean (default = true ) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods.
This parameter can safely be ignored/omitted when calling the constructor.
|
See also
getClass | () | method |
override public function getClass():Class
ReturnsClass |
initRandom1 | () | method |
protected final function initRandom1():void
Initializes this object. See the documentation of the corresponding factory
method newRandom1()
for details.
See also
initRandom2 | () | method |
protected final function initRandom2(seed:LongImpl):void
Initializes this object. See the documentation of the corresponding factory method newRandom2()
for details.
Parameters
seed:LongImpl |
See also
newRandom1 | () | method |
public static function newRandom1():Random
Construct a random generator with the current time of day in milliseconds as the initial state.
ReturnsRandom |
See also
newRandom2 | () | method |
public static function newRandom2(seed:LongImpl):Random
Construct a random generator with the given seed
as the initial state.
Parameters
seed:LongImpl — the seed that will determine the initial state of this random number generator
|
Random |
See also
next | () | method |
protected function next(bits:int):int
Returns a pseudo-random uniformly distributed int
value of the number of bits specified by the argument bits
.
Implements D. H. Lehmer's random number algorithm found in The Art of Computer Programming, Volume 2: Seminumerical Algorithms, by Donald E. Knuth (section 3.2.1).
Parameters
bits:int — number of bits of the returned value
|
int — a pseudo-randomly generated int
|
See also
nextBoolean | () | method |
public function nextBoolean():Boolean
Answers the next pseudo-random, uniformly distributed boolean value generated by this generator.
ReturnsBoolean — boolean a pseudo-random, uniformly distributed boolean value
|
nextBytes | () | method |
public function nextBytes(buf:Vector.<int>):void
Modifies the byte array by a random sequence of bytes generated by this random number generator.
Parameters
buf:Vector.<int> — non-null array to contain the new random bytes
|
See also
nextDouble | () | method |
public function nextDouble():Number
Generates a normally distributed random double number between 0.0 inclusively and 1.0 exclusively.
ReturnsNumber — a random double between 0.0 and 1.0
|
See also
nextFloat | () | method |
public function nextFloat():Number
Generates a normally distributed random float number between 0.0 inclusively and 1.0 exclusively.
ReturnsNumber — a random float between 0.0 and 1.0
|
See also
nextGaussian | () | method |
public function nextGaussian():Number
Returns a pseudo-randomly generated, normally distributed double
value with mean 0.0 and a standard deviation value of 1.0
.
Implements G. E. P. Box, M. E. Muller, and G. Marsaglia's polar method found in The Art of Computer Programming, Volume 2: Seminumerical Algorithms, by Donald E. Knuth (section 3.4.1).
Number — a pseudo-randomly generated double
|
See also
nextInt | () | method |
public function nextInt():int
Generates a uniformly distributed 32-bit int
value from the this random number sequence.
int — a randomly generated int
|
See also
nextInt2 | () | method |
public function nextInt2(n:int):int
Returns a new pseudo-random integer value which is uniformly distributed between 0 (inclusively) and n
(exclusively).
Parameters
n:int — the upper limit of the values that can be returned
|
int — a randomly generated int between 0 and n
|
nextLong | () | method |
public function nextLong():LongImpl
Generates a uniformly distributed 64-bit int
value from the this random
number sequence.
LongImpl — 64-bit int random number
|
See also