Example usage for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getSkewness

List of usage examples for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getSkewness

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.descriptive DescriptiveStatistics getSkewness.

Prototype

public double getSkewness() 

Source Link

Document

Returns the skewness of the available values.

Usage

From source file:com.github.jessemull.microflex.stat.statinteger.SkewnessIntegerTest.java

/**
 * Tests the aggregated plate statistics method using an array.
 *//* w  w w  . j a  v  a 2  s .  c  o  m*/
@Test
public void testAggregatedSetArray() {

    WellSetInteger[] setArray = new WellSetInteger[array.length];

    for (int i = 0; i < setArray.length; i++) {
        setArray[i] = array[i].dataSet();
    }

    Map<WellSetInteger, Double> aggregatedReturnedMap = mean.setsAggregated(setArray);
    Map<WellSetInteger, Double> aggregatedResultMap = new TreeMap<WellSetInteger, Double>();

    for (WellSetInteger set : setArray) {

        List<Double> resultList = new ArrayList<Double>();

        for (WellInteger well : set) {
            resultList.addAll(well.toDouble());
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSkewness();

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSetInteger set : setArray) {

        double result = Precision.round(aggregatedResultMap.get(set), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(set), precision);

        assertTrue(result == returned);
    }

}

From source file:com.github.jessemull.microflexinteger.stat.SkewnessTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the collection.//w w w . j  ava 2  s  . c o  m
 */
@Test
public void testAggregatedSetCollectionIndices() {

    int size = arrayIndices[0].first().size();
    int begin = random.nextInt(size - 5);
    int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

    List<WellSet> collection = new ArrayList<WellSet>();

    for (Plate plate : arrayIndices) {
        collection.add(plate.dataSet());
    }

    Map<WellSet, Double> aggregatedReturnedMap = mean.setsAggregated(collection, begin, end - begin);
    Map<WellSet, Double> aggregatedResultMap = new TreeMap<WellSet, Double>();

    for (WellSet set : collection) {

        List<Double> resultList = new ArrayList<Double>();

        for (Well well : set) {
            resultList.addAll(well.toDouble().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSkewness();

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSet set : collection) {

        double result = Precision.round(aggregatedResultMap.get(set), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(set), precision);

        assertTrue(result == returned);
    }
}

From source file:com.github.jessemull.microflexinteger.stat.SkewnessTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the array.//from   ww  w  . j  av  a 2  s .  c o  m
 */
@Test
public void testAggregatedSetArrayIndices() {

    int size = arrayIndices[0].first().size();
    int begin = random.nextInt(size - 5);
    int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

    WellSet[] setArrayIndices = new WellSet[arrayIndices.length];

    for (int i = 0; i < setArrayIndices.length; i++) {
        setArrayIndices[i] = arrayIndices[i].dataSet();
    }

    Map<WellSet, Double> aggregatedReturnedMap = mean.setsAggregated(setArrayIndices, begin, end - begin);
    Map<WellSet, Double> aggregatedResultMap = new TreeMap<WellSet, Double>();

    for (WellSet set : setArrayIndices) {

        List<Double> resultList = new ArrayList<Double>();

        for (Well well : set) {
            resultList.addAll(well.toDouble().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSkewness();

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSet plate : setArrayIndices) {

        double result = Precision.round(aggregatedResultMap.get(plate), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(plate), precision);

        assertTrue(result == returned);
    }
}

From source file:com.github.jessemull.microflexdouble.stat.SkewnessTest.java

/**
 * Tests the plate statistics method using the values between the indices.
 *///from  w  ww.j a v  a  2  s. com
@Test
public void testPlateIndices() {

    for (Plate plate : arrayIndices) {

        int size = arrayIndices[0].first().size();
        int begin = random.nextInt(size - 5);
        int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = mean.plate(plate, begin, end - begin);

        for (Well well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = stat.getSkewness();

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflexdouble.stat.SkewnessTest.java

/**
 * Tests set calculation using indices.//from   w  w  w  . j av a 2s .  co m
 */
@Test
public void testSetIndices() {

    for (Plate plate : arrayIndices) {

        int size = arrayIndices[0].first().size();
        int begin = random.nextInt(size - 5);
        int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

        Map<Well, Double> resultMap = new TreeMap<Well, Double>();
        Map<Well, Double> returnedMap = mean.set(plate.dataSet(), begin, end - begin);

        for (Well well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = stat.getSkewness();

            resultMap.put(well, result);
        }

        for (Well well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflexdouble.stat.SkewnessTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the collection.//  ww w  .j a v  a 2s .c o m
 */
@Test
public void testAggregatedSetCollectionIndices() {

    int size = arrayIndices[0].first().size();
    int begin = random.nextInt(size - 5);
    int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

    List<WellSet> collection = new ArrayList<WellSet>();

    for (Plate plate : arrayIndices) {
        collection.add(plate.dataSet());
    }

    Map<WellSet, Double> aggregatedReturnedMap = mean.setsAggregated(collection, begin, end - begin);
    Map<WellSet, Double> aggregatedResultMap = new TreeMap<WellSet, Double>();

    for (WellSet set : collection) {

        List<Double> resultList = new ArrayList<Double>();

        for (Well well : set) {
            resultList.addAll(well.data().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSkewness();

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSet set : collection) {

        double result = Precision.round(aggregatedResultMap.get(set), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(set), precision);

        assertTrue(result == returned);
    }
}

From source file:com.github.jessemull.microflexdouble.stat.SkewnessTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices of
 * the array./*from   w  w  w  .ja v  a 2 s . co  m*/
 */
@Test
public void testAggregatedSetArrayIndices() {

    int size = arrayIndices[0].first().size();
    int begin = random.nextInt(size - 5);
    int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

    WellSet[] setArrayIndices = new WellSet[arrayIndices.length];

    for (int i = 0; i < setArrayIndices.length; i++) {
        setArrayIndices[i] = arrayIndices[i].dataSet();
    }

    Map<WellSet, Double> aggregatedReturnedMap = mean.setsAggregated(setArrayIndices, begin, end - begin);
    Map<WellSet, Double> aggregatedResultMap = new TreeMap<WellSet, Double>();

    for (WellSet set : setArrayIndices) {

        List<Double> resultList = new ArrayList<Double>();

        for (Well well : set) {
            resultList.addAll(well.data().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = statAggregated.getSkewness();

        aggregatedResultMap.put(set, aggregatedResult);
    }

    for (WellSet plate : setArrayIndices) {

        double result = Precision.round(aggregatedResultMap.get(plate), precision);
        double returned = Precision.round(aggregatedReturnedMap.get(plate), precision);

        assertTrue(result == returned);
    }
}

From source file:com.github.jessemull.microflexinteger.stat.SkewnessTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *///  w  w  w .  j a v  a 2s . c  om
@Test
public void testAggregatedPlateIndices() {

    for (Plate plate : arrayIndices) {

        int size = arrayIndices[0].first().size();
        int begin = random.nextInt(size - 5);
        int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(mean.platesAggregated(plate, begin, end - begin),
                precision);

        for (Well well : plate) {
            resultList.addAll(well.toDouble().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double aggregatedResult = Precision.round(statAggregated.getSkewness(), precision);

        assertTrue(aggregatedResult == aggregatedReturned);
    }
}

From source file:com.github.jessemull.microflexinteger.stat.SkewnessTest.java

/**
 * Tests the aggregated plate statistics method using the values between the indices.
 *//*  ww w .  j a v a 2  s .  c  o  m*/
@Test
public void testAggregatedSetIndices() {

    for (Plate plate : arrayIndices) {

        int size = arrayIndices[0].first().size();
        int begin = random.nextInt(size - 5);
        int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

        List<Double> resultList = new ArrayList<Double>();
        double aggregatedReturned = Precision.round(mean.setsAggregated(plate.dataSet(), begin, end - begin),
                precision);

        for (Well well : plate) {
            resultList.addAll(well.toDouble().subList(begin, end));
        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = Precision.round(statAggregated.getSkewness(), precision);

        assertTrue(resultAggregated == aggregatedReturned);
    }
}

From source file:com.github.jessemull.microflex.stat.statdouble.SkewnessDoubleTest.java

/**
 * Tests the plate statistics method using the values between the indices.
 *///from www .  j ava 2  s  . c o m
@Test
public void testPlateIndices() {

    for (PlateDouble plate : arrayIndices) {

        int size = arrayIndices[0].first().size();
        int begin = random.nextInt(size - 5);
        int end = (begin + 4) + random.nextInt(size - (begin + 4) + 1);

        Map<WellDouble, Double> resultMap = new TreeMap<WellDouble, Double>();
        Map<WellDouble, Double> returnedMap = mean.plate(plate, begin, end - begin);

        for (WellDouble well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (double bd : well) {
                input[index++] = bd;
                ;
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(ArrayUtils.subarray(input, begin, end));
            double result = stat.getSkewness();

            resultMap.put(well, result);
        }

        for (WellDouble well : plate) {

            double result = Precision.round(resultMap.get(well), precision);
            double returned = Precision.round(returnedMap.get(well), precision);

            assertTrue(result == returned);
        }
    }
}