bedrock_random | R Documentation |
Bedrock Edition's central random number algorithm is MT19937. However, R's MT19937 code is not compatible with Bedrock's. These routines provide an API that is compatible with Bedrock's.
bedrock_random_seed()
seeds the random number generator.
bedrock_random_state()
returns the current state of the random number
generator as a raw vector.
bedrock_random_get_uint()
returns a 32-bit random integer.
Default range is [0, 2^32-1]
.
bedrock_random_get_int()
returns a 31-bit random integer.
Default range is [0, 2^31-1]
.
bedrock_random_get_float()
returns a random real number.
Default range is [0.0, 1.0)
.
bedrock_random_get_double()
returns a random real number
Default range is [0.0, 1.0)
.
bedrock_random_seed(value)
bedrock_random_state(new_state = NULL)
bedrock_random_get_uint(n, max)
bedrock_random_get_int(n, min, max)
bedrock_random_get_float(n, min, max)
bedrock_random_get_double(n)
value |
a scalar integer |
new_state |
a raw vector |
n |
number of observations. |
min , max |
lower and upper limits of the distribution. Must be finite.
If only one is specified, it is taken as |
# seed the global random number generator
bedrock_random_seed(5490L)
# save and restore rng state
saved_state <- bedrock_random_state()
bedrock_random_get_uint(10)
bedrock_random_state(saved_state)
bedrock_random_get_uint(10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.