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