Rand¶
| Spice | |
|---|---|
Functions¶
seed¶
| Spice | |
|---|---|
Seed the pseudo-random number generator. Note: A seed of 0 is replaced by a fixed non-zero constant, as the generator cannot escape the all-zero state.
Parameters
| Name | Type | Description |
|---|---|---|
seedValue |
unsigned long |
Seed value |
randULong¶
| Spice | |
|---|---|
Generate a raw pseudo-random unsigned long, uniformly distributed over the whole 64-bit range.
Returns: unsigned long — Random unsigned long
randInt¶
| Spice | |
|---|---|
Generates a random integer between min and max Note: Both min and max are inclusive: [min, max] Note: If min > max, the function always returns max
Parameters
| Name | Type | Description |
|---|---|---|
min |
int |
|
max |
int |
Returns: int — Random number
randDouble¶
| Spice | |
|---|---|
Generate a random double, uniformly distributed in the half-open interval [0, 1).
Returns: double — Random double in [0, 1)
randDouble¶
| Spice | |
|---|---|
Generate a random double, uniformly distributed in the half-open interval [min, max). Note: If min > max, the function always returns max
Parameters
| Name | Type | Description |
|---|---|---|
min |
double |
Lower bound (inclusive) |
max |
double |
Upper bound (exclusive) |
Returns: double — Random double in [min, max)
randBool¶
| Spice | |
|---|---|
Generate a random boolean value with equal probability for true and false.
Returns: bool — Random boolean
randGaussian¶
| Spice | |
|---|---|
Generate a normally distributed random double with the given mean and standard deviation, using the Box-Muller transform.
Parameters
| Name | Type | Description |
|---|---|---|
mean |
double |
Mean of the distribution |
stdDev |
double |
Standard deviation of the distribution |
Returns: double — Normally distributed random double