ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
alk.cpp
Go to the documentation of this file.
1 #include "statsLib.h"
2 
41 dvar_matrix ageLengthKey(const dvar_vector& mu, const dvar_vector& sig, const dvector& x)
42 {
44  int i, j;
45  dvariable z1;
46  dvariable z2;
47  int si,ni; si=mu.indexmin(); ni=mu.indexmax();
48  int sj,nj; sj=x.indexmin(); nj=x.indexmax()-1;
49  dvar_matrix pdf(si,ni,sj,nj);
50  pdf.initialize();
51  //double xs=0.5*(x[sj+1]-x[sj]);
52  for(i=si;i<=ni;i++) //loop over ages
53  {
54  for(j=sj;j<=nj;j++) //loop over length bins
55  {
56  z1=(x(j)-mu(i))/sig(i);
57  z2=(x(j+1)-mu(i))/sig(i);
58  pdf(i,j)=cumd_norm(z2)-cumd_norm(z1);
59  }//end nbins
60  pdf(i)/=sum(pdf(i));
61  }//end nage
62 
64  return(pdf);
65 }
66 
67 
79 dmatrix ageLengthKey(const dvector& mu, const dvector& sig, const dvector& x)
80 {
82  int i, j;
83  double z1;
84  double z2;
85  int si,ni; si=mu.indexmin(); ni=mu.indexmax();
86  int sj,nj; sj=x.indexmin(); nj=x.indexmax()-1;
87  dmatrix pdf(si,ni,sj,nj);
88  pdf.initialize();
89  //double xs=0.5*(x[sj+1]-x[sj]);
90  for(i=si;i<=ni;i++) //loop over ages
91  {
92  for(j=sj;j<=nj;j++) //loop over length bins
93  {
94  z1=(x(j)-mu(i))/sig(i);
95  z2=(x(j+1)-mu(i))/sig(i);
96  pdf(i,j)=cumd_norm(z2)-cumd_norm(z1);
97  }//end nbins
98  pdf(i)/=sum(pdf(i));
99  }//end nage
100 
102  return(pdf);
103 }
104 
106 {
108  int i, j;
109  dvariable z1;
110  dvariable z2;
111  int si,ni; si=mu.indexmin(); ni=mu.indexmax();
112  int sj,nj; sj=x.indexmin(); nj=x.indexmax();
113  dvar_matrix pdf(si,ni,sj,nj);
114  pdf.initialize();
115  double xs=0.5*(x[sj+1]-x[sj]);
116  for(i=si;i<=ni;i++) //loop over ages
117  {
118  for(j=sj;j<=nj;j++) //loop over length bins
119  {
120  z1=((x(j)-xs)-mu(i))/sig(i);
121  z2=((x(j)+xs)-mu(i))/sig(i);
122  pdf(i,j)=cumd_norm(z2)-cumd_norm(z1);
123  }//end nbins
124  pdf(i)/=sum(pdf(i));
125  }//end nage
126  //pdf/=sum(pdf);
128  return(pdf);
129 }
130 
void RETURN_ARRAYS_DECREMENT(void)
Decrements gradient_structure::RETURN_ARRAYS_PTR.
Definition: gradstrc.cpp:507
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
void initialize(void)
Zero initialize allocated dvar_matrix, then saves adjoint function and position data.
Definition: fvar_ma7.cpp:48
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
ADMB variable vector.
Definition: fvar.hpp:2172
dvar_matrix ageLengthKey(const dvar_vector &mu, const dvar_vector &sig, const dvector &x)
Age Length Key.
Definition: alk.cpp:41
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Description not yet available.
Definition: fvar.hpp:2819
int indexmin() const
Definition: fvar.hpp:2287
Library of statistic functions.
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
void RETURN_ARRAYS_INCREMENT(void)
Increments gradient_structure::RETURN_ARRAYS_PTR.
Definition: gradstrc.cpp:474
double cumd_norm(const double &x)
Culative normal distribution; constant objects.
Definition: cumdist.cpp:90
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat7.cpp:12
int indexmax() const
Definition: fvar.hpp:2292
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
dvar_matrix ALK(dvar_vector mu, dvar_vector sig, dvector x)
Definition: alk.cpp:105