commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shing Hing Man <mat...@yahoo.com>
Subject [Math] Frequency : Is int comparable to Integer through default comparator
Date Wed, 11 Aug 2004 12:19:45 GMT
Deal all,
   It would be appreciated if someone could clarify
the following 
 on 
org.apache.commons.math.stat.univariate.Frequency.

My version of  org.apache.commons.math is dated 10
August, 2004.
The following snippet piece of code is from 

http://jakarta.apache.org/commons/math/userguide/stat.html#1.3%20Frequency%20distributions


  Frequency f = new Frequency();
        f.addValue(1);
        f.addValue(new Integer(1));   // (*)
        f.addValue(new Long(1));
        f.addValue(2);
        f.addValue(new Integer(-1));
        System.out.println(f.getCount(1));   //
displays 3
        System.out.println(f.getCumPct(0));  //
displays 0.2
        System.out.println(f.getPct(new Integer(1))); 
// displays 0.6
        System.out.println(f.getCumPct(-2));   //
displays 0
        System.out.println(f.getCumPct(10));  //
displays 1


When I run it, I got the following exception at line
(*).


Exception in thread "main"
java.lang.IllegalArgumentException: Value not
comparable to
 existing values.

It looks as though the default comparator can not
compare primitive type int with
Integer object. I thought this piece of code is
supposed to demonstrate the otherwise.

Thanks in advice for your help !

Shing


=====
Home page :
  http://uk.geocities.com/matmsh/index.html


	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - all
new features - even more fun!  http://uk.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message