bayes_err: Bayes error

Description Usage Arguments Value Examples

Description

Calculate Bayes error of using true parameters

Usage

1
bayes_err(da, pi0, mu, Sigma, idx)

Arguments

da

Data for clustering

pi0

True clusters weights

mu

True clusters centers

sigma

True clusters covariance

Value

Bayes' classification error

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## First generate data
set.seed(999)
K <- 3;r <- 15; u<- 1;N <- 1000;md=1
da <- data_generation(r, u, N, K, md)
pi0 <- c(0.3, 0.2, 0.5)
idx <- sample(1:K, N, replace = TRUE, prob = pi0)
dat <- matrix(NA, N, r)
for (j in 1:K) {
    if(md <= 3){
      x_tmp <- rmvnorm(sum(idx==j), mean = da$mu[, j], sigma = da$Sigma[, , j])
    }else{ x_tmp <- rmvnorm(sum(idx==j), mean = da$mu[, j], sigma = da$Sigma)}
    dat[idx==j, ] <- x_tmp
}

bayeserr(dat, pi0, da$mu, da$Sigma, idx)

kusakehan/CLEMM documentation built on May 24, 2019, 2:46 p.m.