Home Reference Source
import Random from 'senkowsh/src/konpeito/Random.js'
public class | source

Random

乱数を扱うクラス

Constructor Summary

Public Constructor
public

初期化

Member Summary

Private Members
private

Is keep random numbers based on Gaussian distribution.

private

Next random number based on Gaussian distribution.

Method Summary

Public Methods
public

next(bits: number): number

指定したビット長以下で表せられる乱数生成

public

bool値の乱数

public

8ビット長整数の乱数の配列

public

double精度の実数

public

float精度の実数

public

ガウシアン分布に従う乱数

public

32ビット長整数の乱数

public

64ビット長整数の乱数

public

16ビット長整数の乱数

public

setSeed(seed: number)

シード値の初期化

Private Methods
private

32-bit random number.

Public Constructors

public constructor(seed: number) source

初期化

Params:

NameTypeAttributeDescription
seed number
  • optional

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

Private Members

private haveNextNextGaussian: boolean source

Is keep random numbers based on Gaussian distribution.

private nextNextGaussian: number source

Next random number based on Gaussian distribution.

Public Methods

public next(bits: number): number source

指定したビット長以下で表せられる乱数生成

Params:

NameTypeAttributeDescription
bits number

Required number of bits (up to 64 possible).

Return:

number

public nextBoolean(): boolean source

bool値の乱数

Return:

boolean

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

8ビット長整数の乱数の配列

Params:

NameTypeAttributeDescription
size number

必要な長さ

Return:

Array<number>

public nextDouble(): number source

double精度の実数

Return:

number

public nextFloat(): number source

float精度の実数

Return:

number

public nextGaussian(): number source

ガウシアン分布に従う乱数

Return:

number

public nextInt(x: number): number source

32ビット長整数の乱数

Params:

NameTypeAttributeDescription
x number
  • optional

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

Return:

number

public nextLong(): number source

64ビット長整数の乱数

Return:

number

public nextShort(): number source

16ビット長整数の乱数

Return:

number

public setSeed(seed: number) source

シード値の初期化

Params:

NameTypeAttributeDescription
seed number

Private Methods

private genrand_int32(): number source

32-bit random number.

Return:

number

32ビットの乱数