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.
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){
Create an
ArrayList
. ThisArrayList
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 themclasses
:List<double[]> classes = new ArrayList<double[]>();
Sequentially, add the data from the four classes into
ArrayList
:classes.add(calorie); classes.add(fat); classes.add(carb); ...