Awkl
Loading...
Searching...
No Matches
rnd Namespace Reference

Functions

auto random (X, n, R)
 
bool randBool ()
 Get random uniform boolean.
 
number randU64 (sys)
 Get random uniform 64-bit unsigned integer.
 
number randRange (a, b)
 Get random uniform integer ~U[a,b] or ~U[1,a].
 
auto randRange2 (A, B)
 Random uniform integer in two disjointed ranges.
 
string shuffle (string x)
 

 
unassigned shuffle (array A)
 Shuffle indexed array in-place uniformly.
 
char choice (string x)
 Get random uniform character from string.
 
scalar choice (array A)
 Get random uniform element from array.
 
string randString (string s=str::alnum, number n=8)
 Get uniformly random string.
 
string randString (number n=8)
 Get uniformly random string consisting of certain alphanumeric characters.
 
auto randn ()
 Get random standard normal (gaussian) float ~N(0,1)
 
auto randexp ()
 

 

Variables

string rng = "rand"
 

Function Documentation

◆ choice() [1/2]

scalar rnd::choice ( array A)

Get random uniform element from array.

Parameters
ASource array
Returns
Random element from array

◆ choice() [2/2]

char rnd::choice ( string x)

Get random uniform character from string.

Parameters
xSource string
Returns
Random character from string

◆ randBool()

bool rnd::randBool ( )

Get random uniform boolean.

Returns
Random uniform boolean. mkbool(0) or mkbool(1)

◆ randexp()

auto rnd::randexp ( )


Get random standard exponential float ~Exp(1)

◆ randn()

auto rnd::randn ( )

Get random standard normal (gaussian) float ~N(0,1)

Note
Algorithms for computing a normal from uniforms require independence, which may be an issue if sampling from a poor non-CSPRNG with low internal state/period/statistical properties

◆ random()

auto rnd::random ( X ,
n ,
R  )

◆ randRange()

number rnd::randRange ( a ,
b  )

Get random uniform integer ~U[a,b] or ~U[1,a].

Returns
Random uniform integer
Todo
decimal points parameter, step parameter
Note
Unlike python's which is ~U[a,b>

◆ randRange2()

auto rnd::randRange2 ( A ,
B  )

Random uniform integer in two disjointed ranges.

◆ randString() [1/2]

string rnd::randString ( number n = 8)

Get uniformly random string consisting of certain alphanumeric characters.

Parameters
nLength of resulting string
Returns
Random uniform string of alphanumeric characters, with specific length

◆ randString() [2/2]

string rnd::randString ( string s = str::alnum,
number n = 8 )

Get uniformly random string.

Parameters
sString to get characters from
nLength of resulting string
Returns
Random uniform string of a set of characters, with specific length

◆ randU64()

number rnd::randU64 ( sys )

Get random uniform 64-bit unsigned integer.

Returns
Random number between 0 and 2^64-1

◆ shuffle() [1/2]

unassigned rnd::shuffle ( array A)

Shuffle indexed array in-place uniformly.

Parameters
[in,out]ASource array whose elements are to be suffled in-place
Returns

◆ shuffle() [2/2]

string rnd::shuffle ( string x)


Shuffle characters in a string uniformly

Parameters
xSource string to be shuffled
Returns
String with characters shuffled

Variable Documentation

◆ rng

string rnd::rng = "rand"