Statistics
| Revision:

root / branches / pthreads-737 / docs / manuals / autodif / fcomp_m.cpp @ 765

History | View | Annotate | Download (877 Bytes)

1
\begin{lstlisting}
2
// file fcomp_m.cpp
3

    
4
#include <fvar.hpp>
5
#include "mixture.h"
6

    
7
double fcomp(dvector y,dvar_vector p,dvar_vector& mu,dvar_vector& sd,
8
    dvector& mumin, dvector& mumax, dvector& sdmin, dvector& sdmax,
9
    ivector& control,dvar_vector& x,int print_switch)
10
{
11
  dvariable zpen;
12
  zpen=reset(control,x,p,mu,sd,mumin,mumax,sdmin,sdmax); // Put the
13
                                 // x vector into the model parameters 
14
                                 // and return the bounding function 
15
                                 // penalty in zpen
16
  zpen+=normalize_p(p); // Make the proportions sum to 1
17
  if (print_switch == 1)
18
  {
19
    save_pars(p,mu,sd,mumin,mumax,sdmin,sdmax,control);
20
  }
21
  dvariable f;
22
  f=-log_likelihood(y,p,mu,sd); // Change the sign to minimize
23
  f=f+zpen; // Add the penalty from the bounding functions
24
  return(value(f));
25
}
26
\end{lstlisting}