ADMB Documentation  11.1.2362
 All Classes Files Functions Variables Typedefs Friends Defines
logit.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: logit.cpp 1112 2013-07-12 21:41:41Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00017   dvariable logistic(double a,double b,const prevariable& x)
00018   {
00019     if (value(x)>-20.)
00020     {
00021       dvariable tmp=exp(-x);
00022       return a+(b-a)*1.0/(1.0+tmp);
00023     }
00024     else
00025     {
00026       dvariable tmp=exp(x);
00027       return a+(b-a)*tmp/(1.0+tmp);
00028     }
00029   }
00030 
00035   dvariable log_der_logistic(double a,double b,const prevariable& x)
00036   {
00037     if (value(x)>-20.)
00038     {
00039       dvariable tmp=exp(-x);
00040       return log((b-a)*tmp/square(1.0+tmp));
00041     }
00042     else
00043     {
00044       dvariable tmp=exp(x);
00045       return log((b-a)*tmp/square(1.0+tmp));
00046     }
00047   }
00048 
00053   dvariable dflogistic(double a,double b,const prevariable& x)
00054   {
00055     if (value(x)>-20.)
00056     {
00057       dvariable tmp=exp(-x);
00058       return (b-a)*tmp/square(1.0+tmp);
00059     }
00060     else
00061     {
00062       dvariable tmp=exp(x);
00063       return (b-a)*tmp/square(1.0+tmp);
00064     }
00065   }