public static double BinomialPDF(double p, int n, int k) { //k为成功次数 BigNumber Combination = MathV.Combination(n, k).ToString(); return((double)Combination * Math.Pow(p, k) * Math.Pow(1 - p, n - k)); }
public static double BetaPrediction(int a, int b, int n, int y) { BigInteger Numerator = MathV.Factorial(a + b - 1); BigInteger Denominator = MathV.Factorial(a - 1) * MathV.Factorial(b - 1); BigNumber Quotient = (BigNumber)Numerator.ToString() / (BigNumber)Denominator.ToString(); double NormConst = (double)Quotient; Numerator = MathV.Combination(n, y) * MathV.Factorial(y + a - 1) * MathV.Factorial(n - y + b - 1); Denominator = MathV.Factorial(a + b + n - 1); Quotient = (BigNumber)Numerator.ToString() / (BigNumber)Denominator.ToString(); return(NormConst * (double)Quotient); }