https://github.com/cran/pracma
Tip revision: 708a2ad382a163d1eef5af0665e3ae2aad200ced authored by HwB on 21 March 2013, 00:00:00 UTC
version 1.4.5
version 1.4.5
Tip revision: 708a2ad
sigmoid.R
##
## s i g m o i d . R Sigmoid Function
##
sigmoid <- function(x, a = 1, b = 0) {
if (length(x) == 0) return(c())
stopifnot(is.numeric(x), is.numeric(a), is.numeric(b))
a <- a[1]; b <- b[1]
1 / (1 + exp(-a*(x-b)))
}
logit <- function(x, a = 1, b = 0) {
if (length(x) == 0) return(c())
stopifnot(is.numeric(x), is.numeric(a), is.numeric(b))
a <- a[1]; b <- b[1]
if (x < 0 || x > 1) return(NaN)
if (x >= 0 && x <= 1)
return(b + log(x/(1-x))/a)
else
return(NaN)
}