Skip to content

Commit

Permalink
fix wrong confidence interval formula
Browse files Browse the repository at this point in the history
  • Loading branch information
Red-Portal committed Nov 28, 2023
1 parent 9f25f8a commit af35d16
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "MCMCTesting"
uuid = "9963b6a1-5d46-439c-8efc-3a487843c7fa"
version = "0.3.0"
version = "0.3.1"

[deps]
HypothesisTests = "09f84164-cd44-5f33-b23f-e6b0d136a0d5"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ nothing
```
Then, we can simulate the ranks and then plot them using `Plots`.
```@example started
test = ExactRankTest(10000, 30, 10)
test = ExactRankTest(1000, 10, 10)
rank_correct = simulate_ranks(test, TestSubject(model, Gibbs()); show_progress=false)
rank_wrong = simulate_ranks(test, TestSubject(model, GibbsWrongVar()); show_progress=false)
Expand Down
11 changes: 5 additions & 6 deletions src/rankplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
Plot the simulated ranks using `simulate_ranks`.
If the test subjects are correct, the ranks should visually resemble samples from a uniform distribution.
The black horizontal line shows the density of a uniform distribution, while the colored bands are the 1σ, 2σ, 3σ deviations.
The black horizontal line shows the density of a uniform distribution, while the colored bands are the 1σ, 2σ, 3σ confidence intervals.
!!! info
The deviation bands assume uniform bin sizes.
The confidence intervals are derived from the normal approximation of binomials observations and assume uniformly-sized bins.
!!! info
`Plots` must be imported to use this plot recipe.
Expand All @@ -26,9 +26,8 @@ The black horizontal line shows the density of a uniform distribution, while the
error("rankplot should be given a `<: ExctRankTest` as first argument. Got: $(typeof(h.args)).")
end
test, ranks = h.args

n_max_rank = test.n_mcmc_steps
n_samples = test.n_samples
n_max_rank = test.n_mcmc_steps
n_samples = test.n_samples

xguide --> "Rank"
yguide --> "Count"
Expand All @@ -38,7 +37,7 @@ The black horizontal line shows the density of a uniform distribution, while the
fillalpha --> 0.2

binprob = 1/n_max_rank
binstd = sqrt((1 - binprob)*(binprob))/n_max_rank
binstd = sqrt((1 - binprob)*binprob/n_samples)

# default two-column layout
n_params = size(ranks,1)
Expand Down

4 comments on commit af35d16

@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 register

Release notes:

Changes

  • rankplot shows normalized histograms instead of counts.

@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/96107

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.3.1 -m "<description of version>" af35d166c2117c49b5a1a00b8d5fa947880b2f7a
git push origin v0.3.1

Also, note the warning: Version 0.3.1 skips over 0.3.0
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

@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 register

Release notes:

Changes

  • rankplot shows normalized histograms instead of counts.

@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 updated: JuliaRegistries/General/96107

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.3.1 -m "<description of version>" af35d166c2117c49b5a1a00b8d5fa947880b2f7a
git push origin v0.3.1

Please sign in to comment.