Conducting the one-way ANOVA test

ANOVA stands for Analysis of Variance. In this recipe, we will see how to use Java to do a one-way ANOVA test to determine whether the means of three or more independent and unrelated sets of data points are significantly different.

How to do it...

  1. Create a method that takes various data distributions. In our example, we will be applying ANOVA on relations of calories, fats, carbohydrates, and control:
            public void calculateAnova(double[] calorie, double[] fat, 
              double[] carb, double[] control){
    
  2. Create an ArrayList. This ArrayList will contain all the data. The data distributions the method takes as arguments can be seen as classes. Therefore, in our example, we have named them classes:
     List<double[]> classes = new ...

Get Java Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.