mean value from two dimensional array - Android java.lang

Android examples for java.lang:array calculation

Description

mean value from two dimensional array

Demo Code


//package com.java2s;

public class Main {
    public static double mean2(double[][] a) {
        double[] sum = new double[a.length];
        for (int i = 0; i < sum.length; i++) {
            sum[i] = mean(a[i]);//from w  ww  .  j ava  2 s . co m
        }
        return mean(sum);
    }

    public static double mean(double[] a) {
        double sum = 0;
        for (double i : a) {
            sum += i;
        }
        return sum / a.length;
    }
}

Related Tutorials