All Downloads are FREE. Search and download functionalities are using the official Maven repository.

toolgood.algorithm.mathNet.Distributions.Poisson Maven / Gradle / Ivy

package toolgood.algorithm.mathNet.Distributions;

import toolgood.algorithm.mathNet.SpecialFunctions;

public class Poisson {
        /// 
        /// Computes the probability mass (PMF) at k, i.e. P(X = k).
        /// 
        /// The location in the domain where we want to evaluate the probability mass function.
        /// The lambda (λ) parameter of the Poisson distribution. Range: λ > 0.
        /// the probability mass at location .
        public static double PMF(double lambda, int k)
        {
            //if (!(lambda > 0.0)) {
            //    throw new ArgumentException("InvalidDistributionParameters");
            //}

            return Math.exp(-lambda + (k * Math.log(lambda)) - SpecialFunctions.FactorialLn(k));
        }

        /// 
        /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X ≤ x).
        /// 
        /// The location at which to compute the cumulative distribution function.
        /// The lambda (λ) parameter of the Poisson distribution. Range: λ > 0.
        /// the cumulative distribution at location .
        ///// 
        public static double CDF(double lambda, double x)
        {
            //if (!(lambda > 0.0)) {
            //    throw new ArgumentException("InvalidDistributionParameters");
            //}

            return 1.0 - SpecialFunctions.GammaLowerRegularized(x + 1, lambda);
        }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy