From 7dc8a4266141e2b6ea7191c55e1c26b8b38ce9bd Mon Sep 17 00:00:00 2001 From: Dylan Asmar Date: Fri, 18 Oct 2024 12:49:08 -0600 Subject: [PATCH] Updated jldoctest to use StableRNGs in def_pomdp.md --- docs/Project.toml | 1 + docs/src/def_pomdp.md | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index d714848f..2a2f8757 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -21,6 +21,7 @@ ParticleFilters = "c8b314e2-9260-5cf8-ae76-3be7461ca6d0" QMDP = "3aa3ecc9-5a5d-57c8-8188-3e47bd8068d2" QuickPOMDPs = "8af83fb2-a731-493c-9049-9e19dbce6165" RockSample = "de008ff0-c357-11e8-3329-7fe746fe836e" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" TagPOMDPProblem = "8a653263-a1cc-4cf9-849f-f530f6ffc800" UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" diff --git a/docs/src/def_pomdp.md b/docs/src/def_pomdp.md index 03b0198f..6bff1462 100644 --- a/docs/src/def_pomdp.md +++ b/docs/src/def_pomdp.md @@ -216,15 +216,15 @@ In many cases, especially when the state or observation spaces are continuous or The argument to an `ImplicitDistribution` constructor is a function that takes a random number generator as an argument and returns a sample from the distribution. To see how this works, we'll look at an example inspired by the [mountaincar](@ref po-mountaincar) initial state distribution. Samples from this distribution are position-velocity tuples where the velocity is always zero, but the position is uniformly distributed between -0.2 and 0. Consider the following code: ```jldoctest -using Random: MersenneTwister +using StableRNGs: StableRNG using POMDPTools: ImplicitDistribution -rng = MersenneTwister(1) +rng = StableRNG(1) d = ImplicitDistribution(rng -> (-0.2*rand(rng), 0.0)) rand(rng, d) # output -(-0.04720666913240939, 0.0) +(-0.11703892844248372, 0.0) ``` Here, `rng` is the random number generator. When `rand(rng, d)` is called, the sampling function, `rng -> (-0.2*rand(rng), 0.0)`, is called to generate a state. The sampling function uses `rng` to generate a random number between 0 and 1 (`rand(rng)`), multiplies it by -0.2 to get the position, and creates a tuple with the position and a velocity of `0.0` and returns an initial state that might be, for instance `(-0.11, 0.0)`. Any time that a solver, belief updater, or simulator needs an initial state for the problem, it will be sampled in this way.