Permutation.java [src/java/utils] Revision: default  Date:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import com.google.common.math.Quantiles;
import java.util.List;
import java.util.Map;

public class Permutation {

    double[] vals;
    double exact;
    boolean betweenQuartiles = false;
    boolean betweenMinMax = false;


    Permutation(List<Double> vals, double exact) {
        this.vals = Calc.toDoubleArray(vals);
        this.exact = exact;
        compute();
    }


    private void compute() {
        Map<Integer, Double> uncertResult = Quantiles.quartiles().indexes(0, 1, 2, 3, 4).compute(vals);
        double min = uncertResult.get(0);
        double q1 = uncertResult.get(1);
        double q3 = uncertResult.get(3);
        double max = uncertResult.get(4);

        if (exact < q3 && exact > q1) {
            betweenQuartiles = true;
            betweenMinMax = true;
        } else if (exact < max && exact > min) {
            betweenMinMax = true;
        }
    }


    boolean getQ() {
        return betweenQuartiles;
    }


    boolean getMM() {
        return betweenMinMax;
    }
}