protected double objectiveFunction(double[] x){
      double nll = 0; // -LogLikelihood
      for(int i=0; i<m_Classes.length; i++){ // ith bag
        int nI = m_Data[i][0].length; // numInstances in ith bag
        double bag = 0.0;  // NLL of pos bag

        for(int j=0; j<nI; j++){
          double ins=0.0;
          for(int k=0; k<m_Data[i].length; k++)
            ins += (m_Data[i][k][j]-x[k*2])*(m_Data[i][k][j]-x[k*2])*
              x[k*2+1]*x[k*2+1];
          ins = Math.exp(-ins);
          ins = 1.0-ins;

          if(m_Classes[i] == 1)
            bag += Math.log(ins);
          else{
            if(ins<=m_Zero) ins=m_Zero;
            nll -= Math.log(ins);
          }   
        }		

        if(m_Classes[i] == 1){
          bag = 1.0 - Math.exp(bag);
          if(bag<=m_Zero) bag=m_Zero;
          nll -= Math.log(bag);
        }
      }		
      return nll;
    }