public double[] distributionForInstance(Instance instance) throws Exception {
    double[] probs;
                                               
    //also needed for logitboost
    if (m_isLeaf && m_hasConstr) { //leaf
      //leaf: use majoraty class or constructor model
      probs = modelDistributionForInstance(instance);
    } else {
      if (m_isLeaf && !m_hasConstr)
        {
          probs=new double[instance.numClasses()];
          probs[m_leafclass]=(double)1;  
        }else{
               
        probs = modelDistributionForInstance(instance);
        //Built auxiliary split instance    
        Instance instanceSplit=new Instance(instance.numAttributes()+instance.numClasses());
           
        instanceSplit.setDataset(instance.dataset());
     
        for(int i=0; i< instance.numClasses();i++)
          {
            instanceSplit.dataset().insertAttributeAt( new Attribute("N"+ (instance.numClasses()-i)), 0);
            instanceSplit.setValue(i,probs[i]);
          }
        for(int i=0; i< instance.numAttributes();i++)
          instanceSplit.setValue(i+instance.numClasses(),instance.value(i));
          
           
           
        int branch = m_localModel.whichSubset(instanceSplit); //split
        for(int i=0; i< instance.numClasses();i++)
          instanceSplit.dataset().deleteAttributeAt(0);
            
        //probs = m_sons[branch].distributionForInstance(instance);
        probs = m_sons[branch].distributionForInstance(instance);
      }
    }
    return probs;	
  }