コード例 #1
0
ファイル: Numerics.cs プロジェクト: zhangz/Highlander.Net
        ///// <summary>
        ///// Computes the cumulative distribution function of the binomial distribution.
        ///// </summary>
        ///// <param name="probability">The probability of success per trial.</param>
        ///// <param name="numberOfTrials">The number of trials.</param>
        ///// <param name="valueToCalculate">The value to calculate the distribution for.</param>
        ///// <returns>The calculated value</returns>
        ///// <exception cref="ArgumentOutOfRangeException">If <paramref name="probability"/> is not in the interval [0.0,1.0].</exception>
        ///// <exception cref="ArgumentOutOfRangeException">If <paramref name="numberOfTrials"/> is negative.</exception>
        //public double Binomial(
        //    double probability,
        //    int numberOfTrials,
        //    double valueToCalculate)
        //{
        //    var distribution = new BinomialDistribution(probability, numberOfTrials);
        //    return distribution.CumulativeDistribution(valueToCalculate);
        //}

        /// <summary>
        /// Computes the cumulative distribution function of the lognormal distribution.
        /// </summary>
        /// <param name="probability">The probability of success per trial.</param>
        /// <param name="numberOfTrials">The number of trials.</param>
        /// <param name="valueToCalculate">The value to calculate the distribution for.</param>
        /// <returns>The calculated value</returns>
        /// <exception cref="ArgumentOutOfRangeException">If <paramref name="probability"/> is not in the interval [0.0,1.0].</exception>
        /// <exception cref="ArgumentOutOfRangeException">If <paramref name="numberOfTrials"/> is negative.</exception>
        public double LogNormal(
            double probability,
            int numberOfTrials,
            double valueToCalculate)
        {
            var distribution = new LognormalDistribution(probability, numberOfTrials);

            return(distribution.CumulativeDistribution(valueToCalculate));
        }