Skip to content
Reference > AmiScript API > Classes

Rand

Definition

Rand var = .... ;

Extends

Extended By

None

Method Summary

Owner Name Return Type Description
Rand constructor(seed, secure) Rand Creates a new Randomizer, used for generating random numbers. If a seed is provided, then the numbers generated are the same across runs.
Rand constructor() Rand Creates a new Randomizer, used for generating random numbers
Rand constructor(seed) Rand Creates a new Randomizer, used for generating random numbers. If a seed is provided, then the numbers generated are the same across runs.
Object getClassName() String Returns the string name of this object's class type.
Rand nextBoolean() Boolean Returns a random Boolean value.
Rand nextDouble(min, max) Double Returns a random Double between min and max values.
Rand nextGaussian() Double Return a random signed Double with a mean of 0 and standard deviation of 1.
Rand nextGuid() String Returns a random string.
Rand nextInt(min, max) Integer Returns a random Integer between min and max values.
Rand nextUUID() UUID Returns a randomly generated version 4 UUID object.
Rand shuffle(list) List Returns a new list with the values' positions randomly shuffled.
Object toJson() String Returns a string of a json representation of this object.

Method Definitions


constructor(seed,secure)

Rand rand = new Rand(Number seed, Boolean secure)

Description

Creates a new Randomizer, used for generating random numbers. If a seed is provided, then the numbers generated are the same across runs.

Parameter Definition

Name Type Description
seed Number  seed for repeatability. If null then the seed is random
secure Boolean  if true, then secure. if null or false, then not secure

Example 1

1
2
3
Rand r = new Rand();

// r = java.util.Random@3da1668a

Example 2

1
2
3
Rand r = new Rand(1,true);

// r = java.security.SecureRandom@64cd102e

constructor()

Rand rand = new Rand()

Description

Creates a new Randomizer, used for generating random numbers


constructor(seed)

Rand rand = new Rand(Number seed)

Description

Creates a new Randomizer, used for generating random numbers. If a seed is provided, then the numbers generated are the same across runs.

Parameter Definition

Name Type Description
seed Number  seed for repeatability. If null then the seed is random

getClassName()

String Object::getClassName()

Description

Returns the string name of this object's class type.

Example 14

1
2
3
4
Rand r = new Rand();
r.getClassName();

// r.getClassName() = Rand

nextBoolean()

Boolean Rand::nextBoolean()

Description

Returns a random Boolean value.

Example 1

1
2
3
4
Rand r = new Rand();
r.nextBoolean();

// r.nextBoolean() = true

nextDouble(min,max)

Double Rand::nextDouble(Number min, Number max)

Description

Returns a random Double between min and max values.

Parameter Definition

Name Type Description
min Number  minimum number to be returned (inclusive). If null, then 0
max Number  maximum number to be returned (exclusive). If null, then 1

Example 1

1
2
3
4
Rand r = new Rand();
r.nextDouble(0,10);

// r.nextDouble(0,10) = 7.699758466722869

nextGaussian()

Double Rand::nextGaussian()

Description

Return a random signed Double with a mean of 0 and standard deviation of 1.

Example 1

1
2
3
4
Rand r = new Rand();
r.nextGaussian();

// r.nextGaussian() = 0.8151694377831042

nextGuid()

String Rand::nextGuid()

Description

Returns a random string.

Example 1

1
2
3
4
Rand r = new Rand();
r.nextGuid();

// r.nextGuid() = b50c9e19-5207-cc37-dae0-a95d55f805c3

nextInt(min,max)

Integer Rand::nextInt(Number min, Number max)

Description

Returns a random Integer between min and max values.

Parameter Definition

Name Type Description
min Number  minimum number to be returned (inclusive). If null, then 0
max Number  maximum number to be returned (exclusive). If null, then 1

Example 1

1
2
3
4
Rand r = new Rand();
r.nextInt(0,10);

// r.nextInt(0,10) = 2

nextUUID()

UUID Rand::nextUUID()

Description

Returns a randomly generated version 4 UUID object.

Example 1

1
2
3
4
Rand r = new Rand();
r.nextUUID();

// r.nextUUID() = 41af1228-6556-429e-a08d-f5768f0f5f58

shuffle(list)

List Rand::shuffle(List list)

Description

Returns a new list with the values' positions randomly shuffled.

Parameter Definition

Name Type Description
list List  list of values to shuffle

Example 1

1
2
3
4
5
Rand r = new Rand();
List l = new List("a","b","c");
r.shuffle(l);

// r.shuffle(l) = [b, a, c]

toJson()

String Object::toJson()

Description

Returns a string of a json representation of this object.

Example 14

1
2
3
4
Rand r = new Rand();
r.toJson();

// r.toJson() = "java.util.Random@700f53ae"