ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ccumdlog.cpp
Go to the documentation of this file.
1 
5 #include <fvar.hpp>
6 
7 double inv_cumd_norm_inner(double x);
8 
13 double cumd_logistic(const double& x)
14 {
15  if (x>=0.0)
16  {
17  return 1.0/(1.0+exp(-x));
18  }
19  else
20  {
21  double y=exp(x);
22  return y/(1.0+y);
23  }
24 }
25 
30 double inv_cumd_logistic(const double& x)
31 {
32  return log(x/(1.0-x));
33 }
34 
39 double inv_cumd_norm_logistic(double x,double p)
40 {
41 #if defined(DEBUG)
42  if (0.0<p || 1.0>p)
43  {
44  cerr << "Error in double inv_cumd_norm_logistic -- illegal p value = "
45  << p << endl;
46  ad_exit(1);
47  }
48 #endif
49  cout << log(x) << " ";
50  double y=inv_cumd_logistic(x);
51  cout << log(cumd_norm_logistic(y,p)) << " ";
52  if (y>0)
53  {
54  for (int i=1;i<=10;i++)
55  {
56  double yp=(1.0-p)*0.39894228*exp(-.5*y*y) + p*exp(-y)/square(1.0+exp(-y));
57  y+= 1/yp* (x-cumd_norm_logistic(y,p));
58  cout << cumd_norm_logistic(y,p) << " ";
59  }
60  }
61  else
62  {
63  for (int i=1;i<=10;i++)
64  {
65  double yp=(1.0-p)*0.39894228*exp(-.5*y*y) + p*exp(y)/square(1.0+exp(y));
66  y+= 1/yp* (x-cumd_norm_logistic(y,p));
67  cout << cumd_norm_logistic(y,p) << " ";
68  }
69  }
70  cout << endl;
71  return y;
72 }
73 
78 double cumd_norm_logistic(double _x,double p)
79 {
80  return (1.0-p)*cumd_norm(_x)+p*cumd_logistic(_x);
81 }
#define x
exitptr ad_exit
Definition: gradstrc.cpp:53
double inv_cumd_logistic(const double &x)
Description not yet available.
Definition: ccumdlog.cpp:30
prnstream & endl(prnstream &)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Definition: d3arr2a.cpp:28
double inv_cumd_norm_inner(double x)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: cumdist.cpp:40
double cumd_norm_logistic(double _x, double p)
Description not yet available.
Definition: ccumdlog.cpp:78
double cumd_logistic(const double &x)
Description not yet available.
Definition: ccumdlog.cpp:13
double cumd_norm(const double &x)
Culative normal distribution; constant objects.
Definition: cumdist.cpp:90
double square(const double value)
Return square of value; constant object.
Definition: d3arr4.cpp:16
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13
double inv_cumd_norm_logistic(double x, double p)
Description not yet available.
Definition: ccumdlog.cpp:39