Skip to content

Commit

Permalink
improve docs for rank visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
Red-Portal committed Nov 22, 2023
1 parent 7f42395 commit 9b6488b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions docs/src/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,24 @@ function step(rng::Random.AbstractRNG, model::Model, ::GibbsWrongVar, θ)
end
nothing
```
Then, we can simulate the ranks and then plot them using `Plots.
Then, we can simulate the ranks and then plot them using `Plots`.
```@example started
test = ExactRankTest(1000, 30, 10)
rank_correct = simulate_ranks(test, TestSubject(model, Gibbs()); show_progress=false)
rank_wrong = simulate_ranks(test, TestSubject(model, GibbsWrongVar()); show_progress=false)
param_names = ["θ1 mean", "θ2 mean", "θ1 var", "θ2 var"]
rankplot(test, rank_wrong; param_names)
rankplot!(test, rank_correct; param_names)
stat_names = ["θ1 mean correct", "θ2 mean correct", "θ1 var correct", "θ2 var correct"]
rankplot(test, rank_correct; stat_names)
stat_names = ["θ1 mean wrong", "θ2 mean wrong", "θ1 var wrong", "θ2 var wrong"]
rankplot!(test, rank_wrong; stat_names)
savefig("rankplot.svg")
nothing
```
![](rankplot.svg)

We can see that the ranks of the erroneous kernel are not uniform.
If the MCMC kernel under test is reversible and correct, the ranks must resemble samples from a uniform distribution.
The colored bands around black line show the 1σ, 2σ, and 3σ deviations from the null hypothesis.
Here, we can see that the ranks of the erroneous kernel are not uniform.

2 comments on commit 9b6488b

@Red-Portal
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/95825

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" 9b6488bf259a86adaa6f1064e6997d7657ee387e
git push origin v0.2.1

Please sign in to comment.