Home Reference Source
public class | source

Random

Random number class.

Static Method Summary

Static Public Methods
public static

create(init_data: number | KRandomSettings): *

Create Random.

Constructor Summary

Public Constructor
public

Create Random.

Member Summary

Private Members
private

have NextNextGaussian

private

Normally distributed random numbers.

private

rand: RandomBase

Random Number Generator.

Method Summary

Public Methods
public

next(bits: number): number

Random number of specified bit length.

public

Random boolean.

public

8-bit random number array of specified length.

public

Double type random number in the range of [0, 1).

public

Random numbers from a Gaussian distribution.

public

32-bit random number.

public

setSeed(seed: number)

Initialize random seed.

Static Public Methods

public static create(init_data: number | KRandomSettings): * source

Create Random.

  • algorithm : "XORSHIFT" / "MLS" / "FAST"

Params:

NameTypeAttributeDescription
init_data number | KRandomSettings
  • optional

Seed number for random number generation. If not specified, create from time.

Return:

*

Public Constructors

public constructor(init_data: number | KRandomSettings) source

Create Random.

  • algorithm : "XORSHIFT" / "MLS" / "FAST"

Params:

NameTypeAttributeDescription
init_data number | KRandomSettings
  • optional

Seed number for random number generation. If not specified, create from time.

Private Members

private haveNextNextGaussian: boolean source

have NextNextGaussian

private nextNextGaussian: number source

Normally distributed random numbers.

private rand: RandomBase source

Random Number Generator.

Public Methods

public next(bits: number): number source

Random number of specified bit length.

Params:

NameTypeAttributeDescription
bits number

Required number of bits (up to 64 possible).

Return:

number

public nextBoolean(): boolean source

Random boolean.

Return:

boolean

public nextBytes(size: number): Array<number> source

8-bit random number array of specified length.

Params:

NameTypeAttributeDescription
size number

必要な長さ

Return:

Array<number>

public nextDouble(): number source

Double type random number in the range of [0, 1).

Return:

number

public nextGaussian(): number source

Random numbers from a Gaussian distribution. This random number is a distribution with an average value of 0 and a standard deviation of 1.

Return:

number

public nextInt(x: number): number source

32-bit random number.

Params:

NameTypeAttributeDescription
x number
  • optional

指定した値未満の数値を作る

Return:

number

public setSeed(seed: number) source

Initialize random seed.

Params:

NameTypeAttributeDescription
seed number