SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.rng.RandomPermutation Class Reference

Provides methods to randomly shuffle arrays or lists using a random stream. More...

Static Public Member Functions

static void init (byte[] array, int n)
 Initializes array with the first \(n\) positive integers in natural order as array \([i-1] = i\), for \(i=1,...,n\).
static void init (short[] array, int n)
 Similar to init(byte[], int).
static void init (int[] array, int n)
 Similar to init(byte[], int).
static void init (long[] array, int n)
 Similar to init(byte[], int).
static void init (float[] array, int n)
 Similar to init(byte[], int).
static void init (double[] array, int n)
 Similar to init(byte[], int).
static void shuffle (List<?> list, RandomStream stream)
 Same as java.util.Collections.shuffle(List<?
static void shuffle (Object[] array, RandomStream stream)
 Randomly permutes array using stream.
static void shuffle (byte[] array, RandomStream stream)
 Randomly permutes array using stream.
static void shuffle (short[] array, RandomStream stream)
 Similar to shuffle(byte[], RandomStream).
static void shuffle (int[] array, RandomStream stream)
 Similar to shuffle(byte[], RandomStream).
static void shuffle (long[] array, RandomStream stream)
 Similar to shuffle(byte[], RandomStream).
static void shuffle (char[] array, RandomStream stream)
 Similar to shuffle(byte[], RandomStream).
static void shuffle (boolean[] array, RandomStream stream)
 Similar to shuffle(byte[], RandomStream).
static void shuffle (float[] array, RandomStream stream)
 Similar to shuffle(byte[], RandomStream).
static void shuffle (double[] array, RandomStream stream)
 Similar to shuffle(byte[], RandomStream).
static void shuffle (List<?> list, int k, RandomStream stream)
 Partially permutes list as follows using stream: draws the first.
static void shuffle (Object[] array, int n, int k, RandomStream stream)
 Partially permutes array as follows using stream: draws the new.
static void shuffle (byte[] array, int n, int k, RandomStream stream)
 Similar to shuffle(Object[], n, k, RandomStream).
static void shuffle (short[] array, int n, int k, RandomStream stream)
 Similar to shuffle(Object[], n, k, RandomStream).
static void shuffle (int[] array, int n, int k, RandomStream stream)
 Similar to shuffle(Object[], n, k, RandomStream).
static void shuffle (long[] array, int n, int k, RandomStream stream)
 Similar to shuffle(Object[], n, k, RandomStream).
static void shuffle (char[] array, int n, int k, RandomStream stream)
 Similar to shuffle(Object[], n, k, RandomStream).
static void shuffle (boolean[] array, int n, int k, RandomStream stream)
 Similar to shuffle(Object[], n, k, RandomStream).
static void shuffle (float[] array, int n, int k, RandomStream stream)
 Similar to shuffle(Object[], n, k, RandomStream).
static void shuffle (double[] array, int n, int k, RandomStream stream)
 Similar to shuffle(Object[], n, k, RandomStream).

Detailed Description

Provides methods to randomly shuffle arrays or lists using a random stream.

Definition at line 37 of file RandomPermutation.java.

Member Function Documentation

◆ init() [1/6]

void umontreal.ssj.rng.RandomPermutation.init ( byte[] array,
int n )
static

Initializes array with the first \(n\) positive integers in natural order as array \([i-1] = i\), for \(i=1,...,n\).

The size of array must be at least \(n\).

Parameters
arraythe array to initialize.
nnumber of elements initialized.

Definition at line 49 of file RandomPermutation.java.

◆ init() [2/6]

void umontreal.ssj.rng.RandomPermutation.init ( double[] array,
int n )
static

Similar to init(byte[], int).

Parameters
arraythe array to initialize.
nnumber of elements initialized.

Definition at line 109 of file RandomPermutation.java.

◆ init() [3/6]

void umontreal.ssj.rng.RandomPermutation.init ( float[] array,
int n )
static

Similar to init(byte[], int).

Parameters
arraythe array to initialize.
nnumber of elements initialized.

Definition at line 97 of file RandomPermutation.java.

◆ init() [4/6]

void umontreal.ssj.rng.RandomPermutation.init ( int[] array,
int n )
static

Similar to init(byte[], int).

Parameters
arraythe array to initialize.
nnumber of elements initialized.

Definition at line 73 of file RandomPermutation.java.

◆ init() [5/6]

void umontreal.ssj.rng.RandomPermutation.init ( long[] array,
int n )
static

Similar to init(byte[], int).

Parameters
arraythe array to initialize.
nnumber of elements initialized.

Definition at line 85 of file RandomPermutation.java.

◆ init() [6/6]

void umontreal.ssj.rng.RandomPermutation.init ( short[] array,
int n )
static

Similar to init(byte[], int).

Parameters
arraythe array to initialize.
nnumber of elements initialized.

Definition at line 61 of file RandomPermutation.java.

◆ shuffle() [1/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( boolean[] array,
int n,
int k,
RandomStream stream )
static

Similar to shuffle(Object[], n, k, RandomStream).

Parameters
arraythe array being shuffled.
nselection amongst the first n elements.
knumber of elements selected.
streamthe random stream used to generate random numbers.

Definition at line 477 of file RandomPermutation.java.

◆ shuffle() [2/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( boolean[] array,
RandomStream stream )
static

Similar to shuffle(byte[], RandomStream).

Parameters
arraythe array being shuffled.
streamthe random stream used to generate random numbers.

Definition at line 248 of file RandomPermutation.java.

◆ shuffle() [3/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( byte[] array,
int n,
int k,
RandomStream stream )
static

Similar to shuffle(Object[], n, k, RandomStream).

Parameters
arraythe array being shuffled.
nselection amongst the first n elements.
knumber of elements selected.
streamthe random stream used to generate random numbers.

Definition at line 372 of file RandomPermutation.java.

◆ shuffle() [4/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( byte[] array,
RandomStream stream )
static

Randomly permutes array using stream.

This method permutes the whole array.

Parameters
arraythe array being shuffled.
streamthe random stream used to generate random numbers.

Definition at line 168 of file RandomPermutation.java.

◆ shuffle() [5/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( char[] array,
int n,
int k,
RandomStream stream )
static

Similar to shuffle(Object[], n, k, RandomStream).

Parameters
arraythe array being shuffled.
nselection amongst the first n elements.
knumber of elements selected.
streamthe random stream used to generate random numbers.

Definition at line 456 of file RandomPermutation.java.

◆ shuffle() [6/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( char[] array,
RandomStream stream )
static

Similar to shuffle(byte[], RandomStream).

Parameters
arraythe array being shuffled.
streamthe random stream used to generate random numbers.

Definition at line 232 of file RandomPermutation.java.

◆ shuffle() [7/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( double[] array,
int n,
int k,
RandomStream stream )
static

Similar to shuffle(Object[], n, k, RandomStream).

Parameters
arraythe array being shuffled.
nselection amongst the first n elements.
knumber of elements selected.
streamthe random stream used to generate random numbers.

Definition at line 519 of file RandomPermutation.java.

◆ shuffle() [8/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( double[] array,
RandomStream stream )
static

Similar to shuffle(byte[], RandomStream).

Parameters
arraythe array being shuffled.
streamthe random stream used to generate random numbers.

Definition at line 281 of file RandomPermutation.java.

◆ shuffle() [9/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( float[] array,
int n,
int k,
RandomStream stream )
static

Similar to shuffle(Object[], n, k, RandomStream).

Parameters
arraythe array being shuffled.
nselection amongst the first n elements.
knumber of elements selected.
streamthe random stream used to generate random numbers.

Definition at line 498 of file RandomPermutation.java.

◆ shuffle() [10/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( float[] array,
RandomStream stream )
static

Similar to shuffle(byte[], RandomStream).

Parameters
arraythe array being shuffled.
streamthe random stream used to generate random numbers.

Definition at line 264 of file RandomPermutation.java.

◆ shuffle() [11/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( int[] array,
int n,
int k,
RandomStream stream )
static

Similar to shuffle(Object[], n, k, RandomStream).

Parameters
arraythe array being shuffled.
nselection amongst the first n elements.
knumber of elements selected.
streamthe random stream used to generate random numbers.

Definition at line 414 of file RandomPermutation.java.

◆ shuffle() [12/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( int[] array,
RandomStream stream )
static

Similar to shuffle(byte[], RandomStream).

Parameters
arraythe array being shuffled.
streamthe random stream used to generate random numbers.

Definition at line 200 of file RandomPermutation.java.

◆ shuffle() [13/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( List<?> list,
int k,
RandomStream stream )
static

Partially permutes list as follows using stream: draws the first.

\(k\) new elements of list randomly among the \(n\) old elements of list, assuming that \(k \le n = \) list.size(). In other words, \(k\) elements are selected at random without replacement from the \(n\) list entries and are placed in the first \(k\) positions, in random order.

Parameters
listthe list being shuffled.
knumber of elements selected.
streamthe random stream used to generate integers.

Definition at line 304 of file RandomPermutation.java.

◆ shuffle() [14/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( List<?> list,
RandomStream stream )
static

Same as java.util.Collections.shuffle(List<?

>, Random), but uses a

RandomStream instead of java.util.Random.

Parameters
listthe list being shuffled.
streamthe random stream used to generate integers.

Definition at line 122 of file RandomPermutation.java.

◆ shuffle() [15/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( long[] array,
int n,
int k,
RandomStream stream )
static

Similar to shuffle(Object[], n, k, RandomStream).

Parameters
arraythe array being shuffled.
nselection amongst the first n elements.
knumber of elements selected.
streamthe random stream used to generate random numbers.

Definition at line 435 of file RandomPermutation.java.

◆ shuffle() [16/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( long[] array,
RandomStream stream )
static

Similar to shuffle(byte[], RandomStream).

Parameters
arraythe array being shuffled.
streamthe random stream used to generate random numbers.

Definition at line 216 of file RandomPermutation.java.

◆ shuffle() [17/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( Object[] array,
int n,
int k,
RandomStream stream )
static

Partially permutes array as follows using stream: draws the new.

\(k\) elements, array[0] to array[k-1], randomly among the old \(n\) elements, array[0] to array[n-1], assuming that \(k \le n \le\) array.length. In other words, \(k\) elements are selected at random without replacement from the first \(n\) array elements and are placed in the first \(k\) positions, in random order.

Parameters
arraythe array being shuffled.
nselection amongst the first n elements.
knumber of elements selected.
streamthe random stream used to generate random numbers.

Definition at line 348 of file RandomPermutation.java.

◆ shuffle() [18/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( Object[] array,
RandomStream stream )
static

Randomly permutes array using stream.

This method permutes the whole array.

Parameters
arraythe array being shuffled.
streamthe random stream used to generate random numbers.

Definition at line 151 of file RandomPermutation.java.

◆ shuffle() [19/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( short[] array,
int n,
int k,
RandomStream stream )
static

Similar to shuffle(Object[], n, k, RandomStream).

Parameters
arraythe array being shuffled.
nselection amongst the first n elements.
knumber of elements selected.
streamthe random stream used to generate random numbers.

Definition at line 393 of file RandomPermutation.java.

◆ shuffle() [20/20]

void umontreal.ssj.rng.RandomPermutation.shuffle ( short[] array,
RandomStream stream )
static

Similar to shuffle(byte[], RandomStream).

Parameters
arraythe array being shuffled.
streamthe random stream used to generate random numbers.

Definition at line 184 of file RandomPermutation.java.


The documentation for this class was generated from the following file: