Theoretical Polya Gamma Distribution's Mean and Variance
Source:R/pg_theoretical.R
theoretical-pg.Rd
Compute the theoretical mean and variance for a Polya Gamma variable.
Arguments
- h
A single
integer
value corresponding to the "shape" parameter.- z
A single
numeric
value corresponding to the "scale" parameter.
Examples
# Fixed parameter distribution simulation ----
## Parameters ----
h = 1; z = .5
## Attempt distribution recovery ----
vector_of_pg_samples = rpg_vector(1e6, h, z)
head(vector_of_pg_samples)
#> [,1]
#> [1,] 0.1950715
#> [2,] 0.1565693
#> [3,] 0.1668135
#> [4,] 0.1414704
#> [5,] 0.2935456
#> [6,] 0.3623607
length(vector_of_pg_samples)
#> [1] 1000000
## Obtain the empirical results ----
empirical_mean = mean(vector_of_pg_samples)
empirical_var = var(vector_of_pg_samples)
## Take the theoretical values ----
theoretical_mean = pg_mean(h, z)
theoretical_var = pg_var(h, z)
## Form a comparison table ----
# empirically sampled vs. theoretical values
rbind(c(empirical_mean, theoretical_mean),
c(empirical_var, theoretical_var))
#> [,1] [,2]
#> [1,] 0.24481939 0.2449187
#> [2,] 0.03972714 0.0396598