00001 package commandline.Distributions;
00002
00003 import java.util.ArrayList;
00004
00005 public class Histogram {
00006
00007 int count[];
00012 public Histogram(int number_of_bins){
00013 count =new int[number_of_bins];
00014 }
00015
00016 public int size(){
00017 return count.length;
00018 }
00019
00025 public void addToBin(int binnumber){
00026 count[Math.abs(binnumber)]++;
00027 }
00028
00029 public int getN(int index){
00030 return count[index];
00031 }
00032
00039 public ArrayList<Integer> getNotEmptyBinsBetween(int begin,int end){
00040 ArrayList<Integer> indicesNotNull=new ArrayList<Integer>();
00041 for(int index=begin;index<=end;index++){
00042 if(count[index]!=0){
00043 indicesNotNull.add(index);
00044 }
00045 }
00046 return indicesNotNull;
00047 }
00048
00049 public int getPopulationCount(){
00050 int N=0;
00051 for (int i = 0; i < count.length; i++) {
00052 N+=count[i];
00053 }
00054 return N;
00055 }
00056
00057
00058
00059
00060 }