Esempio n. 1
0
            public static double Binomial(params double[] arguments)
            {
                double n = arguments[0];
                double k = arguments[1];

                return(DoOperators.Factorial(n) / (DoOperators.Factorial(k) * DoOperators.Factorial(n - k)));
            }
Esempio n. 2
0
            public static double Gamma(params double[] arguments)
            {
                //If args[0] is an integer use factorials
                if ((int)arguments[0] == arguments[0])
                {
                    return(DoOperators.Factorial(arguments[0] - 1));
                }

                //Gergő Nemes Approximation
                //https://en.wikipedia.org/wiki/Stirling%27s_approximation
                double z = arguments[0];

                return(Math.Sqrt((2 * Math.PI) / z) * Math.Pow((1 / Math.E) * (z + 1 / (12 * z - 1 / (10 * z))), z));
            }