/** * This will return the bernoulli trial for the given event. * A bernoulli trial is a mechanism for detecting the probability * of a given event occurring k times in n independent trials * @param n the number of trials * @param k the number of times the target event occurs * @param successProb the probability of the event happening * @return the probability of the given event occurring k times. */ public static double bernoullis(double n, double k, double successProb) { double combo = MathUtils.combination(n, k); double q = 1 - successProb; return combo * Math.pow(successProb, k) * Math.pow(q, n - k); }//end bernoullis