Search in sources :

Example 1 with StandardDeviation

use of co.cask.cdap.dq.functions.StandardDeviation in project cdap by caskdata.

the class AggregationFunctionsTest method standardDeviationReturnAggregationTest.

@Test
public void standardDeviationReturnAggregationTest() throws Exception {
    byte[] val1 = Bytes.toBytes(10.0);
    StandardDeviation standardDeviation = new StandardDeviation();
    Double stdevVal = standardDeviation.deserialize(val1);
    Assert.assertEquals(10.0, stdevVal, 0);
}
Also used : StandardDeviation(co.cask.cdap.dq.functions.StandardDeviation) Test(org.junit.Test)

Example 2 with StandardDeviation

use of co.cask.cdap.dq.functions.StandardDeviation in project cdap by caskdata.

the class AggregationFunctionsTest method standardDeviationGenerateAggregationTest.

@Test
public void standardDeviationGenerateAggregationTest() throws Exception {
    DataQualityWritable val1 = new DataQualityWritable();
    val1.set(new DoubleWritable(2.0));
    DataQualityWritable val2 = new DataQualityWritable();
    val2.set(new DoubleWritable(5.0));
    DataQualityWritable val3 = new DataQualityWritable();
    val3.set(new DoubleWritable(10.0));
    DataQualityWritable val4 = new DataQualityWritable();
    val4.set(new DoubleWritable(52.0));
    StandardDeviation standardDeviation = new StandardDeviation();
    standardDeviation.add(val1);
    standardDeviation.add(val2);
    standardDeviation.add(val3);
    standardDeviation.add(val4);
    byte[] output = standardDeviation.aggregate();
    Assert.assertEquals(20.265426, Bytes.toDouble(output), 0.001);
}
Also used : DoubleWritable(org.apache.hadoop.io.DoubleWritable) StandardDeviation(co.cask.cdap.dq.functions.StandardDeviation) DataQualityWritable(co.cask.cdap.dq.DataQualityWritable) Test(org.junit.Test)

Aggregations

StandardDeviation (co.cask.cdap.dq.functions.StandardDeviation)2 Test (org.junit.Test)2 DataQualityWritable (co.cask.cdap.dq.DataQualityWritable)1 DoubleWritable (org.apache.hadoop.io.DoubleWritable)1