Skip to content

Commit

Permalink
Updated jldoctest to use StableRNGs in def_pomdp.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-asmar committed Oct 18, 2024
1 parent 4d0b542 commit 7dc8a42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions docs/src/def_pomdp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 7dc8a42

Please sign in to comment.