package yi.iu.ft;

import java.util.*;
import yi.stat.hist.*;

/**
 * class HistElemProb stores the value probabilty of each histogram member.
 * It will ignore the 0 value since it can be calculated.
 * @deprecated
 */
public class HistElemProb extends HashMap{
  int m_dataNum = 0;

  /**
   * Add a histogram instance to the probabilistic
   * @param hist
   */
  void add(int[] hist) {
    m_dataNum ++;
    for (int i=0; i<hist.length; i++) {
      if (hist[i] != 0) { // should add to corresponding probabilty cumulator
        Integer key = new Integer(i);
        if (!containsKey(key)) put(key, new HashBasedHist());
        HashBasedHist probs = (HashBasedHist)get(key);
        probs.put(hist[i]);
      }
    }
  }

  /**
   * Get the prob (value on that bin) on one bin
   * @param bin
   * @return
   */
  HashBasedHist getProb(int bin) {
    Integer key = new Integer(bin);
    if (!containsKey(key)) return null;
    return (HashBasedHist)get(key);
  }
}

