Here you can find the source of mean(double[][] input, int column)
Parameter | Description |
---|---|
input | a parameter |
column | a parameter |
public static double mean(double[][] input, int column)
//package com.java2s; /*/*from w w w. ja v a2 s . co m*/ * Java Information Dynamics Toolkit (JIDT) * Copyright (C) 2012, Joseph T. Lizier * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { public static double mean(int[] input) { return sum(input) / (double) input.length; } public static double mean(double[] input) { return sum(input) / (double) input.length; } public static double mean(double[] input, int startIndex, int length) { return sum(input, startIndex, length) / (double) length; } public static double mean(double[][] input) { return sum(input) / (double) (input.length * input[0].length); } /** * Compute the mean along the given column * * @param input * @param column * @return */ public static double mean(double[][] input, int column) { return sum(input, column) / (double) input.length; } public static double sum(double[] input) { double total = 0; for (int i = 0; i < input.length; i++) { total += input[i]; } return total; } public static double sum(double[] input, int startIndex, int length) { double total = 0; for (int i = startIndex; i < startIndex + length; i++) { total += input[i]; } return total; } public static double sum(double[][] input) { double total = 0; for (int i = 0; i < input.length; i++) { for (int j = 0; j < input[i].length; j++) { total += input[i][j]; } } return total; } public static double sum(double[][] input, int column) { double total = 0; for (int i = 0; i < input.length; i++) { total += input[i][column]; } return total; } public static double sum(double[][][] input) { double total = 0; for (int i = 0; i < input.length; i++) { for (int j = 0; j < input[i].length; j++) { for (int k = 0; k < input[i][j].length; k++) { total += input[i][j][k]; } } } return total; } public static int sum(int[] input) { int total = 0; for (int i = 0; i < input.length; i++) { total += input[i]; } return total; } public static int sum(int[][] input) { int total = 0; for (int i = 0; i < input.length; i++) { for (int j = 0; j < input[i].length; j++) { total += input[i][j]; } } return total; } public static int sum(int[][][] input) { int total = 0; for (int i = 0; i < input.length; i++) { for (int j = 0; j < input[i].length; j++) { for (int k = 0; k < input[i][j].length; k++) { total += input[i][j][k]; } } } return total; } }