public static boolean test(FlatDataCollection flatDataCollection, double aLevel) {       
            //Note! This test works only for 2 valued internalData. If you have other types of internalData you must transform them into 2 valued internalData.
            int U=0;
            
            Map<Object, Integer> Ni = new HashMap<>();

            Object previousValue=null;
            //Estimate the number of Runs
            for(Object x : flatDataCollection) {
                if(previousValue!=null && !previousValue.equals(x)) {
                    ++U; //if the next value changes count it as different run
                }
                previousValue=x;

                if(Ni.containsKey(x)==false) {
                    Ni.put(x, 1);
                }
                else {
                    Ni.put(x, Ni.get(x) + 1);//keep track of the occurences in each category
                }
            }
            
            //the internalData must be two valued in this test
            if(Ni.size()!=2) {
                throw new IllegalArgumentException("The collection must contain observations from 2 groups.");
            }
            
            Object[] keys = Ni.keySet().toArray();
            int n1= Ni.get(keys[0]);
            int n2= Ni.get(keys[1]);
            //keys = null;
            //Ni = null;

            boolean rejectH0= checkCriticalValue((double)U, n1, n2, aLevel);

            return rejectH0;
    }
public static boolean test ( FlatDataCollection flatDataCollection , double aLevel ) { int U = 0 ; Map < Object , Integer > Ni = new HashMap < > ( ) ; Object previousValue = null ; for ( Object x : flatDataCollection ) { if ( previousValue != null && ! previousValue . equals ( x ) ) { ++ U ; } previousValue = x ; if ( Ni . containsKey ( x ) == false ) { Ni . put ( x , 1 ) ; } else { Ni . put ( x , Ni . get ( x ) + 1 ) ; } } if ( Ni . size ( ) != 2 ) { throw new IllegalArgumentException ( "The collection must contain observations from 2 groups." ) ; } Object [ ] keys = Ni . keySet ( ) . toArray ( ) ; int n1 = Ni . get ( keys [ 0 ] ) ; int n2 = Ni . get ( keys [ 1 ] ) ; boolean rejectH0 = checkCriticalValue ( ( double ) U , n1 , n2 , aLevel ) ; return rejectH0 ; }
Tests the rejection of null Hypothesis for a particular confidence level.

@param flatDataCollection
@param aLevel
@return