Hi,
I have tested all the getter methods of
org.apache.commons.math.stat.univariate.Frequency
when
no data has been added. (If anyone is interested, the
JUnit test file
is attached.)
Here is a summary of the result.
Method Result
getCount returns 0 (as expected)
getCumFreq
java.util.NoSuchElementException
getCumPct
java.util.NoSuchElementException
getPct returns NaN
f.getSumFreq return 0 (as expected)
Is it reasonable to expect all the getter methods to
return 0, when
there is no data ?
My version of org.apache.commons.math is dated 10th
August, 2004.
regards,
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/*
* Test all the getter method in Frequency when there is no data.
*
* Created on 11 August 2004, 14:41
*/
package test.stats;
import junit.framework.*;
import org.apache.commons.math.stat.*;
/**
*
* @author matmsh
*/
public class TestFreq extends TestCase {
private Frequency f ;
private double delta =0.0;
public TestFreq(java.lang.String testName) {
super(testName);
f = new Frequency();
}
public static Test suite() {
TestSuite suite = new TestSuite(TestFreq.class);
return suite;
}
/*
* Test getCount() methods when there is no data.
*/
public void testGetCount(){
assertEquals("getCount(\'a\') should be 0.",0L, f.getCount('a'));
assertEquals("getCount(10) should be 0.",0, f.getCount(10));
assertEquals("getCount(10) should be 0.",0L, f.getCount(10L));
assertEquals("getCount(\"hello\") should be 0.",0L, f.getCount("hello"));
}
/*
* Test getcumFreq() methods when there is no data
*/
public void testGetCumFreq(){
assertEquals("getCumFreq(\'a\') should be 0.",0L, f.getCumFreq('a'));
assertEquals("getCumFreq(10) should be 0.",0, f.getCumFreq(10));
assertEquals("getCumFreq(10) should be 0.",0L, f.getCumFreq(10L));
assertEquals("getCumFreq(\"hello\") should be 0.",0L, f.getCumFreq("hello"));
}
/*
* Test getCumPct() methods when there is no data
*/
public void testGetCumPct(){
assertEquals("getCumPct(\'a\') should be 0.",0.0, f.getCumPct('a'), delta);
assertEquals("getCumPct(10) should be 0.",0.0, f.getCumPct(10), delta);
assertEquals("getCumPct(10) should be 0.",0.0, f.getCumPct(10L), delta);
assertEquals("getCumPct(\"hello\") should be 0.",0.0, f.getCumPct("hello"),delta);
}
/*
* Test getPct() methods when there is no data
*/
public void testGetPct(){
assertEquals("getPct(\'a\') should be 0.",0.0, f.getPct('a'), delta);
assertEquals("getPct(10) should be 0.",0.0, f.getPct(10), delta);
assertEquals("getPct(10) should be 0.",0.0, f.getPct(10L), delta);
assertEquals("getPct(\"hello\") should be 0.",0.0, f.getPct("hello"),delta);
}
/*
* Test getSumFreq when there is no data.
*/
public void testGetSumFreq(){
assertEquals("getSumFreq should be 0.",0L, f.getSumFreq());
}
public static void main(String [] arg){
junit.textui.TestRunner.run(suite());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]