[ADMB Users] cumulative distribution function for beta distribution

dave fournier davef at otter-rsch.com
Thu Sep 29 15:52:25 PDT 2011


Its fairly easy to add using the building on the code Ben pointed out.
Here it is in a tpl file so I could check the derivatives.
Note that you may have to put the operator = into the dvariable class in 
fvar.hpp.



DATA_SECTION
PARAMETER_SECTION
   init_bounded_number a(1,10)
   init_bounded_number b(1,10)
   objective_function_value f
PROCEDURE_SECTION
   f-=mybetai(a,b,.3); f-=mybetai(a,b,.4); f-=mybetai(a,b,.5); 
f-=mybetai(a,b,.6);
GLOBALS_SECTION
   #include <admodel.h>
   #include <df12fun.h>
    df1_two_variable betai(const df1_two_variable& a,
      const df1_two_variable& b,double x,int maxit=100);

   dvariable mybetai(const prevariable& _a,const prevariable& _b,
     double x)
   {
     ADUNCONST(prevariable,a);
     ADUNCONST(prevariable,b);

     init_df1_two_variable va(_a);
     init_df1_two_variable vb(_b);

     df1_two_variable z=betai(va,vb,x);
     dvariable tmp;
     tmp=z;
     return tmp;
   }
  dvariable& dvariable::operator = (const df1_two_variable& v)
   {
     const prevariable * px=df1_two_variable::ind_var[0];
     const prevariable * py=df1_two_variable::ind_var[1];
     double  dfx= *v.get_u_x();
     double  dfy= *v.get_u_y();
     value(*this)=*v.get_u();
     
gradient_structure::GRAD_STACK1->set_gradient_stack(default_evaluation3,
&(value(*this)),&(value(*px)),dfx,&(value(*py)),dfy);
     return *this;
   }




More information about the Users mailing list