Skip to content

Commit

Permalink
Merge branch 'master' into compathelper/new_version/2024-05-10-00-11-…
Browse files Browse the repository at this point in the history
…14-982-03493274693
  • Loading branch information
yebai authored Aug 29, 2024
2 parents c4a650d + 3b35387 commit 8de02c0
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/DocsNav.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Add Navbar

on:
page_build: # Triggers the workflow on push events to gh-pages branch
workflow_dispatch: # Allows manual triggering
schedule:
- cron: '0 0 * * 0' # Runs every week on Sunday at midnight (UTC)

jobs:
add-navbar:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
fetch-depth: 0

- name: Download insert_navbar.sh
run: |
curl -O https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/insert_navbar.sh
chmod +x insert_navbar.sh
- name: Update Navbar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
# Define the URL of the navbar to be used
NAVBAR_URL="https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/TuringNavbar.html"
# Update all HTML files in the current directory (gh-pages root)
./insert_navbar.sh . $NAVBAR_URL
# Remove the insert_navbar.sh file
rm insert_navbar.sh
# Check if there are any changes
if [[ -n $(git status -s) ]]; then
git add .
git commit -m "Added navbar and removed insert_navbar.sh"
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages
else
echo "No changes to commit"
fi
11 changes: 11 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@

Implementation of Julia types for summarizing MCMC simulations and utility functions for [diagnostics](@ref Diagnostics) and [visualizations](@ref StatsPlots.jl).

```@docs
ridgelineplot(chains::Chains, par_names::Vector{Symbol}; hpd_val = [0.05, 0.2],
q = [0.1, 0.9], spacer = 0.5, _riser = 0.2, show_mean = true, show_median = true,
show_qi = false, show_hpdi = true, fill_q = true, fill_hpd = false, ordered = false)
```

```@docs
forestplot(chains::Chains, par_names::Vector{Symbol}; hpd_val = [0.05, 0.2], q = [0.1, 0.9],
spacer = 0.5, _riser = 0.2, show_mean = true, show_median = true, show_qi = false,
show_hpdi = true, fill_q = true, fill_hpd = false, ordered = false)
```
78 changes: 77 additions & 1 deletion docs/src/statsplots.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MCMCChains implements many functions for plotting via [StatsPlots.jl](https://github.com/JuliaPlots/StatsPlots.jl).

## Simple example
## Simple example

The following simple example illustrates how to use Chain to visually summarize a MCMC simulation:

Expand Down Expand Up @@ -90,3 +90,79 @@ autocorplot(chn)
```@example statsplots
corner(chn)
```

For plotting multiple parameters, Ridgeline, Forest and Caterpillar plots can be useful.
Please see the docstrings for a detailed description of these functions.

## Ridgeline

```@example statsplots
ridgelineplot(chn, [:C, :B, :A])
```
""""
ridgelineplot(chains::Chains, par_names::Vector{Symbol}; hpd_val = [0.05, 0.2],
q = [0.1, 0.9], spacer = 0.5, _riser = 0.2, show_mean = true, show_median = true,
show_qi = false, show_hpdi = true, fill_q = true, fill_hpd = false, ordered = false)

Given a `chains` object, returns a Ridgeline plot for the sampled parameters specified on
`par_names`.

For ridgeline plots, the following parameters are defined:

** (a) Fill **
Fill area below the curve can be determined by quantiles interval (`fill_q = true`) or
hdpi interval (`fill_hpd = true`). Default options are `fill_hpd = true` and `fill_q = false`.
If both `fill_q = false` and `fill_hpd = false`, then the whole area below the curve will be
filled. If no fill color is desired, it should be specified with series attributes. These
fill options are mutually exclusive.

** (b) Mean and median **
A vertical line can be plotted repesenting the mean (`show_mean = true`) or median
(`show_median = true`) of the density (kde) distribution. Both options can be plotted at the
same time.

** (c) Intervals **
At the bottom of each density plot, a quantile interval (`show_qi = true`) or HPD interval
(`show_hdpi = true`) can be plotted. These options are mutually exclusive. Default options
are `show_qi = false` and `show_hpdi = true`.To plot quantile intervals, the values specified
as `q` will be taken, and for HPD intervals, only the smaller value specified in `hpd_val`
will be used.

Note: When one parameter is given, it will be plotted as a density plot with all the elements
described above.
"""

## Forest

```@example statsplots
forestplot(chn, [:C, :B, :A], hpd_val = [0.05, 0.15, 0.25])
```

"""
forestplot(chains::Chains, par_names::Vector{Symbol}; hpd_val = [0.05, 0.2],
q = [0.1, 0.9], spacer = 0.5, _riser = 0.2, show_mean = true, show_median = true,
show_qi = false, show_hpdi = true, fill_q = true, fill_hpd = false, ordered = false)

Given a `chains` object, returns a Forest plot for the sampled parameters specified on
`par_names`.

Both `forest` and `caterpillar` plots are called using `forestplot` shorthands.
If `ordered = false`, then a `forest` plot will be returned, and if `ordered = true`,
a `caterpillar` plot will be returned.

For both plot types the following elemets can be plotted:

**High posterior density intervals (HPDI)** determined by the number of elements in `hpd_val`.
All the values in `hpd_val` will be used to construct the intervals with `MCMCChains.hpd.

**Quantile intervals** determined by the 2-element vector `q`.

**Mean and/or median.** Plotted as points with different `markershape..

"""

## Caterpillar

```@example statsplots
forestplot(chn, chn.name_map[:parameters], hpd_val = [0.05, 0.15, 0.25], ordered = true)
```

0 comments on commit 8de02c0

Please sign in to comment.