test_class.declarator: hypergeometric = new Hypergeometric()
test_class.modifier: private static final
test_class.original_string: private static final Hypergeometric hypergeometric = new Hypergeometric();
test_class.type: Hypergeometric
test_class.var_name: hypergeometric
test_class.declarator: EPSILON = 0.00001
test_class.modifier: private static final
test_class.original_string: private static final double EPSILON = 0.00001;
test_class.type: double
test_class.var_name: EPSILON
test_class.file: phenol-analysis/src/test/java/org/monarchinitiative/phenol/stats/HypergeometricTest.java
test_class.identifier: HypergeometricTest
test_case.body: @Test
    void compareTermForTerm4() {
      int m = 13668;
      int m_t = 70;
      int n = 1757;
      int n_t = 19;
      double expected = 0.001022299;
      assertEquals(expected, hypergeometric.phypergeometric(m, m_t, n, n_t), EPSILON);
    }
test_case.class_method_signature: HypergeometricTest.compareTermForTerm4()
test_case.full_signature: @Test void compareTermForTerm4()
test_case.identifier: compareTermForTerm4
test_case.invocations: assertEquals phypergeometric
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void compareTermForTerm4()
focal_class.declarator: lfactorial
focal_class.modifier: private final
focal_class.original_string: private final Vector<Double> lfactorial;
focal_class.type: Vector<Double>
focal_class.var_name: lfactorial
focal_class.file: phenol-analysis/src/main/java/org/monarchinitiative/phenol/stats/Hypergeometric.java
focal_class.identifier: Hypergeometric
focal_class.class_method_signature: Hypergeometric.Hypergeometric()
focal_class.full_signature: public  Hypergeometric()
focal_class.identifier: Hypergeometric
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  Hypergeometric()
focal_class.class_method_signature: Hypergeometric.phypergeometric(int n, double p, int k, int r)
focal_class.full_signature: public double phypergeometric(int n, double p, int k, int r)
focal_class.identifier: phypergeometric
focal_class.modifiers: public
focal_class.parameters: (int n, double p, int k, int r)
focal_class.return: double
focal_class.signature: double phypergeometric(int n, double p, int k, int r)
focal_class.class_method_signature: Hypergeometric.phypergeometric(int m, int m_t, int n, int n_t)
focal_class.full_signature: public double phypergeometric(int m, int m_t, int n, int n_t)
focal_class.identifier: phypergeometric
focal_class.modifiers: public
focal_class.parameters: (int m, int m_t, int n, int n_t)
focal_class.return: double
focal_class.signature: double phypergeometric(int m, int m_t, int n, int n_t)
focal_class.class_method_signature: Hypergeometric.dhyper(int x, int N, int M, int n)
focal_class.full_signature: public double dhyper(int x, int N, int M, int n)
focal_class.identifier: dhyper
focal_class.modifiers: public
focal_class.parameters: (int x, int N, int M, int n)
focal_class.return: double
focal_class.signature: double dhyper(int x, int N, int M, int n)
focal_class.class_method_signature: Hypergeometric.phyper(int x, int N, int M, int n, boolean lowerTail)
focal_class.full_signature: public double phyper(int x, int N, int M, int n, boolean lowerTail)
focal_class.identifier: phyper
focal_class.modifiers: public
focal_class.parameters: (int x, int N, int M, int n, boolean lowerTail)
focal_class.return: double
focal_class.signature: double phyper(int x, int N, int M, int n, boolean lowerTail)
focal_class.class_method_signature: Hypergeometric.lNchooseK(int n, int k)
focal_class.full_signature: public double lNchooseK(int n, int k)
focal_class.identifier: lNchooseK
focal_class.modifiers: public
focal_class.parameters: (int n, int k)
focal_class.return: double
focal_class.signature: double lNchooseK(int n, int k)
focal_class.class_method_signature: Hypergeometric.logfact(int i)
focal_class.full_signature: public double logfact(int i)
focal_class.identifier: logfact
focal_class.modifiers: public
focal_class.parameters: (int i)
focal_class.return: double
focal_class.signature: double logfact(int i)
focal_method.body: public double phypergeometric(int n, double p, int k, int r) {
      /*
       * Study group cannot be larger than population. If this happens there
       * is probably something wrong with the input data, but returning 1.0
       * prevents confusing and wrong output.
       */
      if (k >= n)
        return 1.0;
  
      if (r < 1) {
        return 1.0; // Not valid for r < 2, less than 2 study genes.
      }
  
      double q = 1.0 - p;
      int np = (int) Math.round(n * p); // Round to nearest int
      int nq = (int) Math.round(n * q);
  
      double log_n_choose_k = lNchooseK(n, k);
      int top = k;
      if (np < k) {
        top = np;
      }
  
      double lfoo = lNchooseK(np, top) + lNchooseK(nq, k - top);
  
      double sum = 0.0;
  
      for (int i = top; i >= r; --i) {
        sum += Math.exp(lfoo - log_n_choose_k);
        if (i > r) {
          lfoo = lfoo
            + Math.log((double) i / (double) (np - i + 1))
            + Math.log((double) (nq - k + i)
            / (double) (k - i + 1));
        }
      }
      return sum;
    }
focal_method.class_method_signature: Hypergeometric.phypergeometric(int n, double p, int k, int r)
focal_method.full_signature: public double phypergeometric(int n, double p, int k, int r)
focal_method.identifier: phypergeometric
focal_method.invocations: round round lNchooseK lNchooseK lNchooseK exp log log
focal_method.modifiers: public
focal_method.parameters: (int n, double p, int k, int r)
focal_method.return: double
focal_method.signature: double phypergeometric(int n, double p, int k, int r)