Appendix A

Probability Distributions and Conjugate Atlas

Translating Bayesian derivations into bug-free code hinges on matching mathematical parameterizations to software libraries. This appendix collects every probability distribution used in HoffPeter D. Hoff. A First Course in Bayesian Statistical Methods. Springer Texts in Statistics. Springer, New York, 2009. ISBN 978-0-387-92299-7. doi: 10.1007/978-0-387-92407-6, aligns its exact notation across Hoff, numpy, and scipy.stats, and summarizes all conjugate and semiconjugate updating rules from Chapters 3 through 9.

A.1Common Distributions and Parameterization Map

A.1.1Discrete Distributions

Table A.1: Discrete distributions in Hoff (2009) and their exact Python parameterizations.
DistributionSupportMass Function p(y)p(y)Mean & VariancePython (scipy.stats / numpy)
binary⁡(θ)\operatorname{binary}(\theta){0,1}\{0, 1\}θy(1−θ)1−y\theta^y (1 - \theta)^{1 - y}θ\theta,   θ(1−θ)\;\theta(1-\theta)bernoulli(p=theta) / rng.binomial(1, theta)
binomial⁡(n,θ)\operatorname{binomial}(n, \theta){0,…,n}\{0, \dots, n\}(ny)θy(1−θ)n−y\binom{n}{y}\theta^y(1-\theta)^{n-y}nθn\theta,   nθ(1−θ)\;n\theta(1-\theta)binom(n, p=theta) / rng.binomial(n, theta)
Poisson⁡(θ)\operatorname{Poisson}(\theta){0,1,2,… }\{0, 1, 2, \dots\}θye−θ/y!\theta^y e^{-\theta} / y!θ\theta,   θ\;\thetapoisson(mu=theta) / rng.poisson(theta)
neg-bin⁡(a,b)\operatorname{neg-bin}(a, b) (Hoff){0,1,2,… }\{0, 1, 2, \dots\}Γ(a+y)Γ(y+1)Γ(a)(bb+1)a(1b+1)y\frac{\Gamma(a+y)}{\Gamma(y+1)\Gamma(a)}\bigl(\frac{b}{b+1}\bigr)^a\bigl(\frac{1}{b+1}\bigr)^yab\frac{a}{b},   abb+1b\;\frac{a}{b}\frac{b+1}{b}nbinom(n=a, p=b/(b+1))

A.1.2Continuous Scalar Distributions

Table A.2: Continuous univariate distributions in Hoff (2009) and their exact Python parameterizations.
DistributionSupportDensity p(x)p(x)Mean & VariancePython (scipy.stats / numpy)
beta⁡(a,b)\operatorname{beta}(a, b)(0,1)(0, 1)Γ(a+b)Γ(a)Γ(b)xa−1(1−x)b−1\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)} x^{a-1}(1-x)^{b-1}aa+b\frac{a}{a+b},   ab(a+b)2(a+b+1)\;\frac{ab}{(a+b)^2(a+b+1)}beta(a, b) / rng.beta(a, b)
gamma⁡(a,b)\operatorname{gamma}(a, b) (rate bb)(0,∞)(0, \infty)baΓ(a)xa−1e−bx\frac{b^a}{\Gamma(a)} x^{a-1} e^{-bx}ab\frac{a}{b},   ab2\;\frac{a}{b^2}gamma(a=a, scale=1/b) / rng.gamma(a, 1/b)
inv-gamma⁡(a,b)\operatorname{inv-gamma}(a, b)(0,∞)(0, \infty)baΓ(a)x−(a+1)e−b/x\frac{b^a}{\Gamma(a)} x^{-(a+1)} e^{-b/x}ba−1\frac{b}{a-1} (a>1a>1),   b2(a−1)2(a−2)\;\frac{b^2}{(a-1)^2(a-2)} (a>2a>2)invgamma(a=a, scale=b) or 1 / rng.gamma(a, 1/b)
normal⁡(θ,σ2)\operatorname{normal}(\theta, \sigma^2)ℝ\mathbb{R}(2πσ2)−1/2exp⁡(−(x−θ)22σ2)(2\pi\sigma^2)^{-1/2}\exp\bigl(-\frac{(x-\theta)^2}{2\sigma^2}\bigr)θ\theta,   σ2\;\sigma^2norm(loc=theta, scale=sigma) / rng.normal(theta, sigma)
tν(μ,σ2)t_\nu(\mu, \sigma^2)ℝ\mathbb{R}∝[1+(x−μ)2νσ2]−(ν+1)/2\propto \bigl[1 + \frac{(x-\mu)^2}{\nu\sigma^2}\bigr]^{-(\nu+1)/2}μ\mu (ν>1\nu>1),   νν−2σ2\;\frac{\nu}{\nu-2}\sigma^2 (ν>2\nu>2)t(df=nu, loc=mu, scale=sigma)

A.1.3Multivariate and Matrix-Variate Distributions

Table A.3: Multivariate and matrix-variate distributions in Hoff (2009). Note that multivariate_normal takes the covariance matrix Sigma (unlike scalar norm, which takes standard deviation), and invwishart takes S0 directly rather than S0 inverse.
DistributionSupportDensity KernelMeanPython (scipy.stats / numpy)
𝒩p(𝜽,Σ)\mathcal{N}_p(\boldsymbol{\theta}, \Sigma)ℝp\mathbb{R}^p∣Σ∣−1/2exp⁡(−12(𝐲−𝜽)TΣ−1(𝐲−𝜽))\lvert \Sigma \rvert^{-1/2}\exp\bigl(-\frac{1}{2}(\mathbf{y}-\boldsymbol{\theta})^T \Sigma^{-1}(\mathbf{y}-\boldsymbol{\theta})\bigr)𝜽\boldsymbol{\theta}multivariate_normal(mean=theta, cov=Sigma) / rng.multivariate_normal(theta, Sigma)
Wishart⁡(ν,Ψ)\operatorname{Wishart}(\nu, \Psi)𝒮++p\mathcal{S}_{++}^p∣W∣(ν−p−1)/2exp⁡(−12tr⁡(Ψ−1W))\lvert W \rvert^{(\nu-p-1)/2}\exp\bigl(-\frac{1}{2}\operatorname{tr}(\Psi^{-1}W)\bigr)νΨ\nu \Psiwishart(df=nu, scale=Psi)
inv-Wishart⁡(ν,S0−1)\operatorname{inv-Wishart}(\nu, S_0^{-1})𝒮++p\mathcal{S}_{++}^p∣Σ∣−(ν+p+1)/2exp⁡(−12tr⁡(S0Σ−1))\lvert \Sigma \rvert^{-(\nu+p+1)/2}\exp\bigl(-\frac{1}{2}\operatorname{tr}(S_0 \Sigma^{-1})\bigr)1ν−p−1S0\frac{1}{\nu - p - 1}S_0 (ν>p+1\nu > p+1)invwishart(df=nu, scale=S0)

Warning

The Four Golden Coding Checks.

  1. Scalar norm / rng.normal expects standard deviation σ\sigma; multivariate_normal expects covariance Σ\Sigma (squared scale!).
  2. gamma and rng.gamma expect scale =1/rate= 1/\text{rate} (1/b1/b), whereas Hoff’s gamma⁡(a,b)\operatorname{gamma}(a, b) uses rate bb.
  3. invgamma(a=a, scale=b) expects bb directly (matching 1 / rng.gamma(shape=a, scale=1/b)).
  4. invwishart(df=nu, scale=S0) expects S0S_0 directly (not S0−1S_0^{-1}), matching Hoff’s inverse-Wishart⁡(ν,S0−1)\operatorname{inverse-Wishart}(\nu, S_0^{-1}).

A.2Conjugate and Semiconjugate Updating Atlas

Table A.4: Master conjugate and semiconjugate updating table spanning Parts I through III.
Chapter & ModelPriorPosterior / Full Conditional
Ch. 3: Y∣θ∼bin⁡(n,θ)Y \mid \theta \sim \operatorname{bin}(n, \theta)θ∼beta⁡(a,b)\theta \sim \operatorname{beta}(a, b)θ∣y∼beta⁡(a+y, b+n−y)\theta \mid y \sim \operatorname{beta}(a + y,\, b + n - y)
Ch. 3: Yi∣θ∼Poisson⁡(θ)Y_i \mid \theta \sim \operatorname{Poisson}(\theta)θ∼gamma⁡(a,b)\theta \sim \operatorname{gamma}(a, b)θ∣y∼gamma⁡(a+∑yi, b+n)\theta \mid y \sim \operatorname{gamma}(a + \sum y_i,\, b + n)
Ch. 5: Yi∣θ,σ2∼𝒩(θ,σ2)Y_i \mid \theta, \sigma^2 \sim \mathcal{N}(\theta, \sigma^2) (joint conjugate)θ∣σ2∼𝒩(μ0,σ2/κ0)\theta \mid \sigma^2 \sim \mathcal{N}(\mu_0, \sigma^2/\kappa_0),   σ−2∼gamma⁡(ν02,ν0σ022)\;\sigma^{-2} \sim \operatorname{gamma}(\frac{\nu_0}{2}, \frac{\nu_0\sigma_0^2}{2})θ∣σ2,y∼𝒩(μn,σ2/κn)\theta \mid \sigma^2, y \sim \mathcal{N}(\mu_n, \sigma^2/\kappa_n),   σ−2∣y∼gamma⁡(νn2,νnσn22)\;\sigma^{-2} \mid y \sim \operatorname{gamma}(\frac{\nu_n}{2}, \frac{\nu_n\sigma_n^2}{2})
Ch. 6: Yi∣θ,σ2∼𝒩(θ,σ2)Y_i \mid \theta, \sigma^2 \sim \mathcal{N}(\theta, \sigma^2) (semiconjugate)θ∼𝒩(μ0,τ02)\theta \sim \mathcal{N}(\mu_0, \tau_0^2),   σ−2∼gamma⁡(ν02,ν0σ022)\;\sigma^{-2} \sim \operatorname{gamma}(\frac{\nu_0}{2}, \frac{\nu_0\sigma_0^2}{2})θ∣σ2,y∼𝒩(τn2(μ0τ02+ny¯σ2),τn2)\theta \mid \sigma^2, y \sim \mathcal{N}\bigl(\tau_n^2(\frac{\mu_0}{\tau_0^2} + \frac{n\bar{y}}{\sigma^2}), \tau_n^2\bigr);   σ−2∣θ,y∼gamma⁡(ν0+n2,ν0σ02+∑(yi−θ)22)\;\sigma^{-2} \mid \theta, y \sim \operatorname{gamma}\bigl(\frac{\nu_0+n}{2}, \frac{\nu_0\sigma_0^2 + \sum(y_i-\theta)^2}{2}\bigr)
Ch. 7: 𝐘i∣𝜽,Σ∼𝒩p(𝜽,Σ)\mathbf{Y}_i \mid \boldsymbol{\theta}, \Sigma \sim \mathcal{N}_p(\boldsymbol{\theta}, \Sigma)𝜽∼𝒩p(𝝁0,Λ0)\boldsymbol{\theta} \sim \mathcal{N}_p(\boldsymbol{\mu}_0, \Lambda_0),   Σ∼IW⁡(ν0,S0−1)\;\Sigma \sim \operatorname{IW}(\nu_0, S_0^{-1})𝜽∣Σ,𝐘∼𝒩p(𝝁n,Λn)\boldsymbol{\theta} \mid \Sigma, \mathbf{Y} \sim \mathcal{N}_p(\boldsymbol{\mu}_n, \Lambda_n);   Σ∣𝜽,𝐘∼IW⁡(ν0+n,(S0+𝐒𝜽)−1)\;\Sigma \mid \boldsymbol{\theta}, \mathbf{Y} \sim \operatorname{IW}\bigl(\nu_0+n, (S_0 + \mathbf{S}_{\boldsymbol{\theta}})^{-1}\bigr)
Ch. 9: 𝐲∣𝜷,σ2∼𝒩n(𝐗𝜷,σ2In)\mathbf{y} \mid \boldsymbol{\beta}, \sigma^2 \sim \mathcal{N}_n(\mathbf{X}\boldsymbol{\beta}, \sigma^2 I_n) (gg-prior)𝜷∣σ2∼𝒩p(𝟎,gσ2(𝐗T𝐗)−1)\boldsymbol{\beta} \mid \sigma^2 \sim \mathcal{N}_p(\mathbf{0}, g\sigma^2(\mathbf{X}^T\mathbf{X})^{-1}),   σ−2∼gamma⁡(ν02,ν0σ022)\;\sigma^{-2} \sim \operatorname{gamma}(\frac{\nu_0}{2}, \frac{\nu_0\sigma_0^2}{2})𝜷∣σ2,𝐲∼𝒩p(gg+1𝜷^ols, gg+1σ2(𝐗T𝐗)−1)\boldsymbol{\beta} \mid \sigma^2, \mathbf{y} \sim \mathcal{N}_p\bigl(\frac{g}{g+1}\hat{\boldsymbol{\beta}}_{\text{ols}},\, \frac{g}{g+1}\sigma^2(\mathbf{X}^T\mathbf{X})^{-1}\bigr);   σ−2∣𝐲∼gamma⁡(ν0+n2,ν0σ02+SSR⁡g2)\;\sigma^{-2} \mid \mathbf{y} \sim \operatorname{gamma}\bigl(\frac{\nu_0+n}{2}, \frac{\nu_0\sigma_0^2 + \operatorname{SSR}_g}{2}\bigr)