1 |
Xquanti |
|
mean |
|
sigma |
|
Y |
|
Xijh |
|
alpha_k |
|
K |
|
n |
|
p |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (Xquanti, mean, sigma, Y, Xijh, alpha_k, K = length(sigma),
n = nrow(Xquanti), p = length(colnames(Xquali)))
{
if (p == 0) {
p <- 1
}
fk_quali_ik <- matrix(1, nrow = n, ncol = length(unique(Y)))
K = length(unique(Y))
for (i in 1:n) {
for (k in 1:K) {
for (j in 1:p) {
fk_quali_ik[i, k] <- fk_quali_ik[i, k] * (as.numeric(alpha_k[[k]][[j]][["proba"]] %*%
as.numeric(Xijh[[j]][i, -length(Xijh[[j]][i,
])])))
}
}
}
fk_quati_ik <- matrix(1, nrow = n, ncol = length(unique(Y)))
p = length(colnames(Xquanti))
if (p == 0) {
p <- 1
}
for (i in 1:n) {
for (k in 1:K) {
fk_quati_ik[i, k] <- (1/(((2 * pi)^(p/2)) * (det(as.matrix(sigma[[k]]))^(0.5)))) *
exp((Xquanti[i, ] - as.numeric(mean[k, -1])) %*%
ginv(as.matrix(sigma[[k]])) %*% as.matrix(Xquanti[i,
] - as.numeric(mean[k, -1])) * (-0.5))
}
}
fkxi <- as.list(seq_len(nrow(Xquanti)))
for (i in 1:n) {
fkxi[[i]] <- data.frame(densite = fk_quali_ik[i, ] *
fk_quati_ik[i, ])
}
return(fkxi)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.