package net.ranides.assira.math;

import net.ranides.assira.collection.query.CQuery;
import org.junit.Test;

import static org.junit.Assert.*;

public class MathStatsTest {

    @Test
    public void mode() {
        CQuery<Integer> v1 = CQuery.from().values(1, 2, 5, 5, 3, 2, 7, 2, 1, 2, 1, 5, 9);
        assertEquals((Integer) 2, MathStats.mode(v1).getValue());
        assertEquals(4, MathStats.mode(v1).getCount());
    }

    @Test
    public void deviation() {
        CQuery<Integer> v1 = CQuery.from().values(1, 2, 3, 4, 5, 5, 6, 7, 8, 9);
        assertEquals(5.0, MathStats.deviation(v1).getAverage(), 0.1);
        assertEquals(2.4, MathStats.deviation(v1).getDeviation(), 0.1);
    }
}