Java examples for java.lang:Math Number
Returns chi-square probability for even numbers number.
//package com.java2s; public class Main { /**//from w w w . j av a 2 s . c o m * Returns chi-square probability for even numbers number. */ public static double chiSquareProbEven(int number, double value) { double result = 0; for (int idx = 0; idx <= (number / 2 - 1); idx++) { result += (1 / gammaFunction(idx + 1)) * Math.pow(value / 2, idx); } return Math.exp(-value / 2) * result; } /** * Returns gamma value for a double in. */ public static double gammaFunction(double in) { if (in == 1.0) { return 1.0; } if (in == 0.5) { return Math.sqrt(Math.PI); } return (in - 1) * gammaFunction(in - 1); } }