/**
 * Copyright (C) 2013-2017 Vasilis Vryniotis 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.datumbox.framework.core.statistics.descriptivestatistics;

import com.datumbox.framework.common.dataobjects.DataTable2D;
import com.datumbox.framework.core.common.dataobjects.Dataframe;
import com.datumbox.framework.common.dataobjects.TransposeDataList;
import com.datumbox.framework.common.dataobjects.TypeInference;
import com.datumbox.framework.core.statistics.nonparametrics.relatedsamples.KendallTauCorrelation;
import com.datumbox.framework.core.statistics.nonparametrics.relatedsamples.SpearmanCorrelation;
import com.datumbox.framework.core.statistics.parametrics.relatedsamples.PearsonCorrelation;

import java.util.Map;

/**
 * The Bivariate class enables us to estimate correlation metrics between different
 * variables.
 *
 * @author Vasilis Vryniotis 
 */
public class Bivariate {
    
    private enum BivariateType  {
        COVARIANCE, PEARSONCORRELATION, SPEARMANCORRELATION, KENDALLTAUCORRELATION
    };
    
    /**
     * Calculates BivariateMatrix for a given statistic
     * 
     * @param dataSet
     * @param type
     * @return 
     */
    private static DataTable2D bivariateMatrix(Dataframe dataSet, BivariateType type) {
        DataTable2D bivariateMatrix = new DataTable2D();
        
        //extract values of first variable
        Map columnTypes = dataSet.getXDataTypes();
        Object[] allVariables = columnTypes.keySet().toArray();
        int numberOfVariables = allVariables.length;
        
        TransposeDataList transposeDataList;
        for(int i=0;i 

Ads help maintain this website.