# Matt's trick / central formulation of beta distribution?

**URL:** https://discourse.pymc.io/t/matts-trick-central-formulation-of-beta-distribution/1728
**Category:** Questions
**Created:** [August 14, 2018, 5:53pm UTC](https://discourse.pymc.io/t/matts-trick-central-formulation-of-beta-distribution/1728 "2018-08-14T17:53:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Maria](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/maria/32/1038_2.png) [@Maria](https://discourse.pymc.io/u/Maria)
#### Post date: [August 14, 2018, 5:53pm UTC](https://discourse.pymc.io/t/matts-trick-central-formulation-of-beta-distribution/1728/1 "2018-08-14T17:53:57Z")

</div>

Sorry if this is a very basic question!

I know that “Matt’s trick” can help avoid divergent samples and the sampler getting stuck. I was wondering if there’s an equivalent trick for distributions other than the normal distribution? I’d like to use a Beta distribution for my parameter “beta”.

Matt’s trick for Normal distribution:

```auto
with pm.Model() as model:

    beta_mu = pm.Uniform('beta_mu', lower=0, upper=5, testval=1.25)
    beta_sd = pm.Uniform('beta_sd', lower=0, upper=5, testval=0.1)
    beta_matt = pm.Normal('beta_matt', mu=0, sd=1, shape=n_subj, testval=np.random.choice([-0.1, 0, 0.1], n_subj))
    beta = pm.Deterministic('beta', beta_mu + beta_sd * beta_matt)

```

Is there an equivalent for the Beta distribution? Thanks in advance!!

---

<div class="post-metadata">

### Author: ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)
#### Post date: [August 14, 2018, 6:34pm UTC](https://discourse.pymc.io/t/matts-trick-central-formulation-of-beta-distribution/1728/2 "2018-08-14T18:34:22Z")

</div>

You can have a look at the recent paper [Implicit Reparameterization Gradients](https://arxiv.org/pdf/1805.08498.pdf), many of the tricks should also apply. Also see [https://en.wikipedia.org/wiki/Beta\_distribution#Related\_distributions](https://en.wikipedia.org/wiki/Beta_distribution#Related_distributions)
