尖度 kurtosis 計算 java

apacheのをシステムに合わせた

参考リンク

http://www.google.com/codesearch?hl=ja&q=Kurtosis+lang:java+show:8f3GQEQS6uc:A67jy6J5uck:8f3GQEQS6uc&sa=N&cd=1&ct=rc&cs_p=http://svn.apache.org/repos/asf/commons/proper/math/&cs_f=tags/MATH_1_1_RC5/src/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java

	/**
	* Returns the kurtosis of the entries in the specified portion of the
	* input array.
	* <p>
	* See {@link Kurtosis} for details on the computing algorithm.
	* <p>
	* Throws <code>IllegalArgumentException</code> if the array is null.
	* http://www.google.com/codesearch?hl=ja&q=Kurtosis+lang:java+show:8f3GQEQS6uc:A67jy6J5uck:8f3GQEQS6uc&sa=N&cd=1&ct=rc&cs_p=http://svn.apache.org/repos/asf/commons/proper/math/&cs_f=tags/MATH_1_1_RC5/src/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java
	*
	* @param values 配列 the input array
	* @param stdDev 標準偏差
	* @param mean 平均値
	* @return the kurtosis of the values or Double.NaN if length is less than
	* 4
	* @throws IllegalArgumentException if the input array is null or the array
	* index parameters are not valid
	*/
	public double evaluateKurtosis(final Double[] values,double stdDev,double mean) {
	    // Initialize the kurtosis
	    double kurt = Double.NaN;
	    int length = values.length;
	
	
		// first make sure that array has enough elements
		if (length < 3) {
			String s = "Array with less than three elements passed to DescriptiveStatistics.skewness";
			System.out.println(s);
			return Double.NaN;
		} // end if
	
	    // Sum the ^4 of the distance from the mean divided by the
	    // standard deviation
	    double accum3 = 0.0;
	    for (int i = 0; i < length; i++) {
	        accum3 += Math.pow((values[i] - mean), 4.0);
	    }
	    accum3 /= Math.pow(stdDev, 4.0d);
	
	    // Get N
	    double n0 = length;
	
	    double coefficientOne =
	        (n0 * (n0 + 1)) / ((n0 - 1) * (n0 - 2) * (n0 - 3));
	    double termTwo =
	        ((3 * Math.pow(n0 - 1, 2.0)) / ((n0 - 2) * (n0 - 3)));
	
	    // Calculate kurtosis
	    kurt = (coefficientOne * accum3) - termTwo;
	
	    return kurt;
	}

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2008-11-21 (金) 20:19:40 (3859d)