#' logistic function with D=1.7
#'
#' @param x vector
#' @param D = 1.7
#' @details This function calculates \cr
#'   p=1/(1+exp(-D*x)) \cr
#' @return vector of the size of x
#' @export
#'

logistic <- function( x, D=1.7 ){
 # logistic function
 # Shin-ichi Mayekawa
 # 20150418 cot,19
 # no minp: 20150622
 #
 return( 1/(1+exp(-D*x)) )
} # end of logistic


#' logit function with D=1.7
#'
#' @param p vector
#' @param D = 1.7
#' @details This function calculates \cr
#'   x=log(p/(1-p))
#' @return vector of the size of p
#' @export
#'

logit <- function( p, D=1.7 ){
 # inverse of logistic function
 # Shin-ichi Mayekawa
 # no minp: 20150622
 return( log(p/(1-p))/D )
} # end of logit



#' logistic function with D and minimum value
#'
#' @param x vector
#' @param D = 1.7
#' @param minp minimum value of the function
#' @details This function calculates \cr
#'   p=1/(1+exp(-D*x)) \cr
#' and applies minp as \cr
#'   p[p<minp]=minp; p[p>1-minp]=1-minp
#' @return vector of the size of x
#' @export
#'

logistic1 <- function( x, D=1.7, minp=10e-9 ){
 # logistic function
 # Shin-ichi Mayekawa
 # 20150418 cot,19
 # renamed as 1: 20150622
 #
 p=1/(1+exp(-D*x))
 p[p<minp]=minp; p[p>1-minp]=1-minp
 return( p )
} # end of logistic


#' logit function with D and minimum value
#'
#' @param p vector
#' @param D = 1.7
#' @param minp minimum value of the function
#' @details This function calculates \cr
#'   x=log(p/(1-p))
#' at the following p values \cr
#'   p[p<minp]=minp; p[p>1-minp]=1-minp
#' @return vector of the size of p
#' @export
#'

logit1 <- function( p, D=1.7, minp=1e-9 ){
 # inverse of logistic function
 # Shin-ichi Mayekawa
 # renamed as 1: 20150622
 p[p<minp]=minp; p[p>1-minp]=1-minp
 x=log(p/(1-p))
 return( x/D )
} # end of logit



