Here you can find the source of meanEnt(double[] nums)
Parameter | Description |
---|---|
nums | the numbers |
public static double meanEnt(double[] nums)
//package com.java2s; /*/*from ww w .j a va2 s. co m*/ Copyright (C) 2010, 2011 Constantine Lignos This file is a part of CATS. CATS 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. CATS 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 CATS. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Return the mean entropy of the logs of the numbers given. * @param nums the numbers * @return sum of logs of numbers */ public static double meanEnt(double[] nums) { return logProb(nums) / nums.length; } /** * Return the sum of the logs of the numbers given. * @param nums the numbers * @return sum of logs of numbers */ public static double logProb(double[] nums) { double sum = 0; for (int i = 0; i < nums.length; i++) { sum += Math.log(nums[i]); } return sum; } }