sufficientStatistics_Weighted.GaussianGaussian {bbricks} | R Documentation |
For following model structure:
x \sim Gaussian(mu,Sigma)
mu \sim Gaussian(m,S)
Where Sigma is known. Gaussian() is the Gaussian distribution. See ?dGaussian
for the definition of Gaussian distribution.
The sufficient statistics of a set of samples x (each row of x is a sample) and weights w are:
the effective number of samples N=sum(w)
the sample sum xsum = colSums(x*w)
## S3 method for class 'GaussianGaussian' sufficientStatistics_Weighted(obj, x, w, foreach = FALSE, ...)
obj |
A "GaussianGaussian" object. |
x |
matrix, Gaussian samples, when x is a matrix, each row is a sample of dimension ncol(x). when x is a vector, x is length(x) samples of dimension 1. |
w |
numeric, sample weights. |
foreach |
logical, specifying whether to return the sufficient statistics for each observation. Default FALSE. |
... |
Additional arguments to be passed to other inherited types. |
If foreach=TRUE, will return a list of sufficient statistics for each row of x, otherwise will return the sufficient statistics of x as a whole.
Gelman, Andrew, et al. Bayesian data analysis. CRC press, 2013.
GaussianGaussian
, sufficientStatistics.GaussianGaussian
obj <- GaussianGaussian(gamma=list(Sigma=matrix(c(2,1,1,2),2,2),m=c(0.2,0.5),S=diag(2))) x <- rGaussian(100,c(0,0),Sigma = matrix(c(2,1,1,2),2,2)) w <- runif(100) sufficientStatistics_Weighted(obj=obj,x=x,w=w,foreach = FALSE) sufficientStatistics_Weighted(obj=obj,x=x,w=w,foreach = TRUE)