Skip to contents

Given a Dirichlet process prior with precision alpha and base measure value G0_A on a set A, and n_in_A of n observations falling in A, returns the mean and variance of the (beta) posterior of \(G(A)\). The posterior mean is the precision- weighted mixture of prior and empirical mass; the variance is that of a beta with the updated precision alpha + n.

Usage

morie_gh_dp_posterior(G0_A, alpha, n_in_A, n)

Arguments

G0_A

prior base-measure mass \(G_0(A)\) of the set, in \([0, 1]\)

alpha

Dirichlet-process precision (positive)

n_in_A

number of observations falling in A

n

total number of observations; if zero the empirical mass is taken as 0

Value

list with elements mean (posterior mean of \(G(A)\)), var (posterior variance) and precision (the updated precision alpha + n)

References

Ghosal, S. and van der Vaart, A. (2017). Fundamentals of Nonparametric Bayesian Inference. Cambridge University Press.

Examples

morie_gh_dp_posterior(G0_A = c(1, 2, 3, 4, 5, 6, 7, 8), alpha = 0.5,
  n_in_A = c(1, 2, 3, 4, 5, 6, 7, 8), n = 5L)
#> $mean
#> [1] 0.2727273 0.5454545 0.8181818 1.0909091 1.3636364 1.6363636 1.9090909
#> [8] 2.1818182
#> 
#> $var
#> [1]  0.03051494  0.03814367  0.02288620 -0.01525747 -0.07628735 -0.16020343
#> [7] -0.26700572 -0.39669421
#> 
#> $precision
#> [1] 5.5
#>