@Test public void testHypergeometric() { logger.info("Hypergeometric"); int k = 3; int n = 10; int Kp = 30; int Np = 100; double expResult = 0.28116339430254; double result = DiscreteDistributions.hypergeometric(k, n, Kp, Np); assertEquals(expResult, result, Constants.DOUBLE_ACCURACY_HIGH); }
public static double hypergeometric(int k, int n, int Kp, int Np) { if(k<0 || n<0 || Kp<0 || Np<0) { throw new IllegalArgumentException("All the parameters must be positive."); } Kp = Math.max(k, Kp); Np = Math.max(n, Np); double probability = approxHypergeometricCdf(k,n,Kp,Np); if(k>0) { probability -= approxHypergeometricCdf(k-1,n,Kp,Np); } return probability; }
DiscreteDistributions { public static double hypergeometric(int k, int n, int Kp, int Np) { if(k<0 || n<0 || Kp<0 || Np<0) { throw new IllegalArgumentException("All the parameters must be positive."); } Kp = Math.max(k, Kp); Np = Math.max(n, Np); double probability = approxHypergeometricCdf(k,n,Kp,Np); if(k>0) { probability -= approxHypergeometricCdf(k-1,n,Kp,Np); } return probability; } }
DiscreteDistributions { public static double hypergeometric(int k, int n, int Kp, int Np) { if(k<0 || n<0 || Kp<0 || Np<0) { throw new IllegalArgumentException("All the parameters must be positive."); } Kp = Math.max(k, Kp); Np = Math.max(n, Np); double probability = approxHypergeometricCdf(k,n,Kp,Np); if(k>0) { probability -= approxHypergeometricCdf(k-1,n,Kp,Np); } return probability; }  }
DiscreteDistributions { public static double hypergeometric(int k, int n, int Kp, int Np) { if(k<0 || n<0 || Kp<0 || Np<0) { throw new IllegalArgumentException("All the parameters must be positive."); } Kp = Math.max(k, Kp); Np = Math.max(n, Np); double probability = approxHypergeometricCdf(k,n,Kp,Np); if(k>0) { probability -= approxHypergeometricCdf(k-1,n,Kp,Np); } return probability; }  static double bernoulli(boolean k, double p); static double bernoulliCdf(int k, double p); static double binomial(int k, double p, int n); static double binomialCdf(int k, double p, int n); static double geometric(int k, double p); static double geometricCdf(int k, double p); static double negativeBinomial(int n, int r, double p); static double negativeBinomialCdf(int n, int r, double p); static double uniform(int n); static double uniformCdf(int k, int n); static double hypergeometric(int k, int n, int Kp, int Np); static double hypergeometricCdf(int k, int n, int Kp, int Np); static double poisson(int k, double lamda); static double poissonCdf(int k, double lamda); }
DiscreteDistributions { public static double hypergeometric(int k, int n, int Kp, int Np) { if(k<0 || n<0 || Kp<0 || Np<0) { throw new IllegalArgumentException("All the parameters must be positive."); } Kp = Math.max(k, Kp); Np = Math.max(n, Np); double probability = approxHypergeometricCdf(k,n,Kp,Np); if(k>0) { probability -= approxHypergeometricCdf(k-1,n,Kp,Np); } return probability; }  static double bernoulli(boolean k, double p); static double bernoulliCdf(int k, double p); static double binomial(int k, double p, int n); static double binomialCdf(int k, double p, int n); static double geometric(int k, double p); static double geometricCdf(int k, double p); static double negativeBinomial(int n, int r, double p); static double negativeBinomialCdf(int n, int r, double p); static double uniform(int n); static double uniformCdf(int k, int n); static double hypergeometric(int k, int n, int Kp, int Np); static double hypergeometricCdf(int k, int n, int Kp, int Np); static double poisson(int k, double lamda); static double poissonCdf(int k, double lamda);  }