Variable
Static Public Summary | ||
public |
Sample a single element from an array. |
|
public |
Returns a double in interval [i, j[ (i included, j excluded) according to a uniform distribution. |
|
public |
Returns an integer in interval [i, j[ (i included, j excluded) according to a uniform distribution. |
|
public |
Pick an element from range(start, stop, step) uniformly at random. |
|
public |
Reservoir sampling. |
|
public |
Take a sample of size n (without replacement) from the items i through j-1 of the input array. |
|
public |
Shuffle array in-place between positions i and j-1 (inclusive). |
|
public |
Given an input iterable, constructs an array containing the elements of the input shuffled uniformly at random. |
Static Public
public choice(a: Array, i: number, j: number): any: * source
import choice from '@randomized/random/src/api/choice.js'
Sample a single element from an array.
Return:
any | The sampled element. |
public randfloat(i: number, j: number): number: * source
import randfloat from '@randomized/random/src/api/randfloat.js'
Returns a double in interval [i, j[ (i included, j excluded) according to a uniform distribution.
public randint(i: number, j: number): number: * source
import randint from '@randomized/random/src/api/randint.js'
Returns an integer in interval [i, j[ (i included, j excluded) according to a uniform distribution.
public randrange(start: number, stop: number, step: number): number: * source
import randrange from '@randomized/random/src/api/randrange.js'
Pick an element from range(start, stop, step) uniformly at random.
Return an element from range(start, stop, step) selected uniformly at random.
If step is positive, this set corresponds to
{x: x in [start, stop[ AND x % step = 0}.
If step is negative, the range has to be given in reverse order, that is,
largest value first, smallest value second. Both the starting value and the
step value are optional. By default the starting value is 0
.
The default for the step value is 1
.
TODO: Handle empty ranges.
public reservoir(k: number, iterable: Iterable, output: Array): Array: * source
import reservoir from '@randomized/random/src/api/reservoir.js'
Reservoir sampling.
public sample(n: number, a: Array, i: number, j: number): * source
import sample from '@randomized/random/src/api/sample.js'
Take a sample of size n (without replacement) from the items i through j-1 of the input array. This is done in-place. The sample can be retrieved from position i to i+n.
public shuffle(a: Array, i: number, j: number): * source
import shuffle from '@randomized/random/src/api/shuffle.js'
Shuffle array in-place between positions i and j-1 (inclusive). The other positions are left untouched.
public shuffled(iterable: Iterable): Array: * source
import shuffled from '@randomized/random/src/api/shuffled.js'
Given an input iterable, constructs an array containing the elements of the input shuffled uniformly at random.