R/e.scal.R

Defines functions e.scal

Documented in e.scal

e.scal<-function(x, k = 1, tc = NULL)
{
    scal <- function(k, x)
    {
        xx <- exp(k * x)
        return(xx / rowSums(xx))
    }
    scal2 <- function(k, x, tc)
    {
        xx <- scal(k, x)
        ec <- factor(max.col(xx), levels = seq(along = colnames(xx)), 
            labels = colnames(xx))
        return(mean(ec != tc))
    }
    if(!is.null(tc)) {
        k <- optimize(scal2, c(0, 1000), x = x, tc = tc)$minimum
    }
    x <- scal(k, x)
    return(list(sv = x, k = k))
}

Try the klaR package in your browser

Any scripts or data that you put into this service are public.

klaR documentation built on May 29, 2024, 5:20 a.m.