public static double getPvalue ( TransposeDataList transposeDataList ) { Object [ ] keys = transposeDataList . keySet ( ) . toArray ( ) ; if ( keys . length != 2 ) { throw new IllegalArgumentException ( "The collection must contain observations from 2 groups." ) ; } Object keyX = keys [ 0 ] ; Object keyY = keys [ 1 ] ; FlatDataList flatDataListX = transposeDataList . get ( keyX ) ; FlatDataList flatDataListY = transposeDataList . get ( keyY ) ; int n = flatDataListX . size ( ) ; if ( n <= 0 || n != flatDataListY . size ( ) ) { throw new IllegalArgumentException ( "The number of observations in each group must be equal and larger than 0." ) ; } int Tplus = 0 ; for ( int j = 0 ; j < n ; ++ j ) { double delta = flatDataListX . getDouble ( j ) - flatDataListY . getDouble ( j ) ; if ( delta == 0 ) { continue ; //don't count it at all } if ( delta > 0 ) { ++ Tplus ; } } double pvalue = scoreToPvalue ( Tplus , n ) ; return pvalue ; }
Estimates the p - value of the sign test for the provided data .