public double computeEntropy(SampleSet set){
	double entropy = 0.0;
	int pos=0,neg=0,total=0;
	boolean status = true;
	Iterator<Sample> it;
	Sample sample =null;
	//Sort by this attribute.
	java.util.Collections.sort(set.getSamples(),this);
	//count number of positive and negative examples
	for(Sample s : set.getSamples()){
		if(s.getResult())pos++;
		else neg++;
	}
	total=pos+neg;
	entropy = super.computeEntropy(neg,pos);
	
	int posSoFar=0, negSoFar=0;
	double currentEntropy;
	it=set.getSamples().iterator();
	sample = it.next();
	status = sample.getResult();
	if (status)posSoFar++;
	else negSoFar++;
	while(it.hasNext()){
		sample = it.next();
		//no change in result => just increment counters
		if (sample.getResult()==status){
			if (status) posSoFar++;
			else negSoFar++;
		}
		// change in result ==> update entropy, if lower.
		else{
			currentEntropy = 0.0;
			currentEntropy += ((posSoFar+negSoFar)/total)*super.computeEntropy(negSoFar,posSoFar);
			currentEntropy += ((total-posSoFar-negSoFar)/total)*super.computeEntropy(neg-negSoFar,pos-posSoFar);
			if(currentEntropy < entropy){
				this.splitValue=sample.getValue(this.id).doubleValue();
				entropy = currentEntropy;
			}
			if (sample.getResult()) posSoFar++;
			else negSoFar++;
		}
	}
	return entropy;
	}