Skip to contents

For \((\pi_1, \ldots, \pi_k) \sim Dir(\alpha)\) with \(A = \sum_i \alpha_i\), returns \(E[\pi_j]\), \(Var[\pi_j]\) and \(Cov[\pi_j, \pi_{j'}]\). The covariance is computed from the formula for distinct cells; passing j == jp therefore does not reproduce the variance.

Usage

morie_gh_dirichlet_moments(alpha, j, jp)

Arguments

alpha

numeric vector of Dirichlet concentration parameters

j

index of the cell whose mean and variance are wanted

jp

index of the second cell for the covariance

Value

list with elements mean, var (both for cell j) and cov (between cells j and jp)

References

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

Examples

morie_gh_dirichlet_moments(alpha = 0.5, j = c(1, 2, 3, 4, 5, 6, 7, 8),
  jp = c(1, 2, 3, 4, 5, 6, 7, 8))
#> $mean
#> [1]  1 NA NA NA NA NA NA NA
#> 
#> $var
#> [1]  0 NA NA NA NA NA NA NA
#> 
#> $cov
#> [1]  0 NA NA NA NA NA NA NA
#>