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

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

package toolgood.algorithm.mathNet.Distributions;

import toolgood.algorithm.mathNet.SpecialFunctions;

public class Hypergeometric {
     /// 
        /// 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 size of the population (N).
        /// The number successes within the population (K, M).
        /// The number of draws without replacement (n).
        /// the probability mass at location .
        public static double PMF(int population, int success, int draws, int k)
        {
            //if (!(population >= 0 && success >= 0 && draws >= 0 && success <= population && draws <= population)) {
            //    throw new ArgumentException("InvalidDistributionParameters");
            //}

            return SpecialFunctions.Binomial(success, k) * SpecialFunctions.Binomial(population - success, draws - k) / SpecialFunctions.Binomial(population, draws);
        }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy