# Posterior predictive check with custom pdf (censored shifted Wald)

**URL:** <https://discourse.mc-stan.org/t/posterior-predictive-check-with-custom-pdf-censored-shifted-wald/7681>\
**Category:** Modeling\
**Tags:** cognitive-science\
**Created:** [February 12, 2019, 5:29pm UTC](https://discourse.mc-stan.org/t/posterior-predictive-check-with-custom-pdf-censored-shifted-wald/7681 "2019-02-12T17:29:10Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![maxbiostat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/maxbiostat/32/1326_2.png) [@maxbiostat](https://discourse.mc-stan.org/u/maxbiostat)\
**Post date:** [February 12, 2019, 11:53pm UTC](https://discourse.mc-stan.org/t/posterior-predictive-check-with-custom-pdf-censored-shifted-wald/7681/3 "2019-02-12T23:53:20Z")

</div>

I’m by no means an expert on the Wald distribution. But Google tells me it also likes to go by the name of Inverse Gaussian.

Wikipedia lists an [algorithm](https://en.wikipedia.org/wiki/Inverse_Gaussian_distribution#Generating_random_variates_from_an_inverse-Gaussian_distribution) for generating a random variate from an inverse Gaussian. It seems straight-forward enough to do. Except in your case you need some sort of shifting or censoring, so I’m not sure. Maybe you could generate the variate and reject those below the threshold or something.

Another way of doing it would be to write an inverse CDF function using the algebraic solver [going to go out on a limb here and claim there is no closed-form inverse CDF for this distribution] and then apply [this](https://discourse.mc-stan.org/t/rng-for-truncated-distributions/3122/7) cool trick by @lcomm.

---

_[View the full topic](https://discourse.mc-stan.org/t/posterior-predictive-check-with-custom-pdf-censored-shifted-wald/7681)._
