get.var: Internal function. With stratified samples, calculate the variance of the estimate from importance sampling without control variates
Description
Internal function. With stratified samples, calculate the variance of the estimate from importance sampling without control variates
Usage
get.var(Y, nvec)
Arguments
Y
vector of stratified samples of length $n$. i.e. $Y_1 = Y[1:nvec[1]]$ are sampled from $q_1$, $Y_i = Y[(nvec[i-1]+1):nvec[i]]$ are sample from $q_i$.
nvec
the vector of number of samples from each mixture component. It sums up to $n$.
Value
the variance estimate of $\hat{\mu} = 1/n \sum_{i=1}^n Y[i]$
Details
Suppose we sample Y from a mixture $q_{\alpha} = \alpha_1*q_1 + ... + \alpha_J*q_J$. To estimate $\mathrm{mean}(Y)$, fixing the number of samples from each mixture component and getting a stratified sample would reduce the variance of the estimate. The formula for $\mathrm{Var}(\hat{\mu})$ with stratified samples is $$\mathrm{Var}(\hat{\mu}) = 1/n \times \sum_{j=1}^J \alpha_j \mathrm{Var}(Y_j)$$