pg.moments: Polya-Gamma Distribution Moments

pg.m1R Documentation

Polya-Gamma Distribution Moments

Description

Compute the first moment (mean), second moment, and variance of the Polya-Gamma distribution PG(b, z).

Usage

pg.m1(b, z)
pg.m2(b, z)
pg.var(b, z)

Arguments

b

Shape parameter. Must be positive.

z

Tilt parameter. May be any real number.

Details

For X \sim \mathrm{PG}(b, z), the moments are derived from the moment generating function

E[e^{tX}] = \left( \frac{\cosh(z/2)}{\cosh(\sqrt{z^2/4 - t/2})} \right)^b.

The first moment is

E[X] = \frac{b \tanh(z/2)}{2z}, \quad z \neq 0,

with E[X] = b/4 when z = 0. Taylor series are used near z = 0 for numerical stability.

pg.m2 returns E[X^2], and pg.var returns \mathrm{Var}(X) = E[X^2] - E[X]^2.

Value

A scalar giving the requested moment.

References

Nicholas G. Polson, James G. Scott, and Jesse Windle. Bayesian inference for logistic models using Polya-Gamma latent variables. https://arxiv.org/abs/1205.0310

See Also

rpg

Examples

## Mean and variance of PG(1, 0)
pg.m1(1, 0)   # 0.25
pg.var(1, 0)  # 1/24

## Compare sample moments to theoretical values
set.seed(1)
x <- rpg(10000, h = 2, z = 1)
mean(x)
pg.m1(2, 1)

var(x)
pg.var(2, 1)

BayesLogit documentation built on June 6, 2026, 9:06 a.m.