@Override public double[][] predictIntervals(double conf){
  updateBoundariesAndOrWeights();
  double val=Statistics.normalInverse(1.0 - (1.0 - conf) / 2);
  double min=m_TM.firstKey() - val * m_Width;
  double max=m_TM.lastKey() + val * m_Width;
  double delta=(max - min) / m_NumIntervals;
  double[] probabilities=new double[m_NumIntervals];
  double leftVal=Math.exp(logDensity(min));
  for (int i=0; i < m_NumIntervals; i++) {
    double rightVal=Math.exp(logDensity(min + (i + 1) * delta));
    probabilities[i]=0.5 * (leftVal + rightVal) * delta;
    leftVal=rightVal;
  }
  int[] sortedIndices=Utils.sort(probabilities);
  double sum=0;
  boolean[] toUse=new boolean[probabilities.length];
  int k=0;
  while ((sum < conf) && (k < toUse.length)) {
    toUse[sortedIndices[toUse.length - (k + 1)]]=true;
    sum+=probabilities[sortedIndices[toUse.length - (k + 1)]];
    k++;
  }
  probabilities=null;
  ArrayList<double[]> intervals=new ArrayList<double[]>();
  double[] interval=null;
  boolean haveStartedInterval=false;
  for (int i=0; i < m_NumIntervals; i++) {
    if (toUse[i]) {
      if (haveStartedInterval == false) {
        haveStartedInterval=true;
        interval=new double[2];
        interval[0]=min + i * delta;
      }
      interval[1]=min + (i + 1) * delta;
    }
 else {
      if (haveStartedInterval) {
        haveStartedInterval=false;
        intervals.add(interval);
      }
    }
  }
  if (haveStartedInterval) {
    intervals.add(interval);
  }
  return intervals.toArray(new double[0][0]);
}

@ Override public double [ ] [ ] predictIntervals ( double conf ) { updateBoundariesAndOrWeights ( ) ; double val = Statistics . normalInverse ( 1.0 - ( 1.0 - conf ) / 2 ) ; double min = m_TM . firstKey ( ) - val * m_Width ; double max = m_TM . lastKey ( ) + val * m_Width ; double delta = ( max - min ) / m_NumIntervals ; double [ ] probabilities = new double [ m_NumIntervals ] ; double leftVal = Math . exp ( logDensity ( min ) ) ; for ( int i = 0 ; i < m_NumIntervals ; i ++ ) { double rightVal = Math . exp ( logDensity ( min + ( i + 1 ) * delta ) ) ; probabilities [ i ] = 0.5 * ( leftVal + rightVal ) * delta ; leftVal = rightVal ; } int [ ] sortedIndices = Utils . sort ( probabilities ) ; double sum = 0 ; boolean [ ] toUse = new boolean [ probabilities . length ] ; int k = 0 ; while ( ( sum < conf ) && ( k < toUse . length ) ) { toUse [ sortedIndices [ toUse . length - ( k + 1 ) ] ] = true ; sum += probabilities [ sortedIndices [ toUse . length - ( k + 1 ) ] ] ; k ++ ; } probabilities = null ; ArrayList < double [ ] > intervals = new ArrayList < double [ ] > ( ) ; double [ ] interval = null ; boolean haveStartedInterval = false ; for ( int i = 0 ; i < m_NumIntervals ; i ++ ) { if ( toUse [ i ] ) { if ( haveStartedInterval == false ) { haveStartedInterval = true ; interval = new double [ 2 ] ; interval [ 0 ] = min + i * delta ; } interval [ 1 ] = min + ( i + 1 ) * delta ; } else { if ( haveStartedInterval ) { haveStartedInterval = false ; intervals . add ( interval ) ; } } } if ( haveStartedInterval ) { intervals . add ( interval ) ; } return intervals . toArray ( new double [ 0 ] [ 0 ] ) ; }
returns the interval for the given confidence value .
