Esempio n. 1
0
        public static string DirichletPrediction(List <int> Numbers, List <int> Alphas)
        {
            BigInteger Denominator = 1;
            int        k           = Alphas.Count;

            for (int i = 0; i < k; i++)
            {
                Denominator *= MathV.Factorial(Numbers[i]);
            }
            BigInteger Numerator = MathV.Factorial(Numbers.Sum());
            BigNumber  Factor1   = (((BigNumber)Numerator.ToString()) / ((BigNumber)Denominator.ToString())).ToString();

            Denominator = 1;
            for (int i = 0; i < k; i++)
            {
                Denominator *= MathV.Factorial(Alphas[i] - 1);
            }
            Numerator = MathV.Factorial(Alphas.Sum() - 1);
            BigNumber Factor2 = (((BigNumber)Numerator.ToString()) / ((BigNumber)Denominator.ToString())).ToString();

            Denominator = MathV.Factorial(Alphas.Sum() + Numbers.Sum() - 1);
            Numerator   = 1;
            for (int i = 0; i < k; i++)
            {
                Numerator *= MathV.Factorial(Alphas[i] + Numbers[i] - 1);
            }
            BigNumber Factor3 = (((BigNumber)Numerator.ToString()) / ((BigNumber)Denominator.ToString())).ToString();
            BigNumber Result  = Factor1 * Factor2 * Factor3;

            return(Result.ToString());
        }
Esempio n. 2
0
        public static double BetaPDF(double x, int a, int b)
        {
            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;

            return(NormConst * Math.Pow(x, a - 1) * Math.Pow(1 - x, b - 1));
        }
Esempio n. 3
0
        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);
        }