public static double calculateCorrelation(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];
        
        FlatDataCollection flatDataCollectionX = transposeDataList.get(keyX).toFlatDataCollection();
        FlatDataCollection flatDataCollectionY = transposeDataList.get(keyY).toFlatDataCollection();

        int n = flatDataCollectionX.size();
        if(n<=2 || n!=flatDataCollectionY.size()) {
            throw new IllegalArgumentException("The number of observations in each group must be equal and larger than 2.");
        }

        double stdX= Descriptives.std(flatDataCollectionX,true);
        double stdY=Descriptives.std(flatDataCollectionY,true);

        double covariance=Descriptives.covariance(transposeDataList,true);

        double pearson=covariance/(stdX*stdY);

        return pearson;
    }
public static double calculateCorrelation ( 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 ] ; FlatDataCollection flatDataCollectionX = transposeDataList . get ( keyX ) . toFlatDataCollection ( ) ; FlatDataCollection flatDataCollectionY = transposeDataList . get ( keyY ) . toFlatDataCollection ( ) ; int n = flatDataCollectionX . size ( ) ; if ( n <= 2 || n != flatDataCollectionY . size ( ) ) { throw new IllegalArgumentException ( "The number of observations in each group must be equal and larger than 2." ) ; } double stdX = Descriptives . std ( flatDataCollectionX , true ) ; double stdY = Descriptives . std ( flatDataCollectionY , true ) ; double covariance = Descriptives . covariance ( transposeDataList , true ) ; double pearson = covariance / ( stdX * stdY ) ; return pearson ; }
Calculates Pearson's Correlation for a given transposed array (2xn table)

@param transposeDataList
@return