code: public static function NEGBINOMDIST($failures, $successes, $probability)
      {
          $failures = floor(Functions::flattenSingleValue($failures));
          $successes = floor(Functions::flattenSingleValue($successes));
          $probability = Functions::flattenSingleValue($probability);
  
          if ((is_numeric($failures)) && (is_numeric($successes)) && (is_numeric($probability))) {
              if (($failures < 0) || ($successes < 1)) {
                  return Functions::NAN();
              } elseif (($probability < 0) || ($probability > 1)) {
                  return Functions::NAN();
              }
              if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
                  if (($failures + $successes - 1) <= 0) {
                      return Functions::NAN();
                  }
              }
  
              return (MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * (pow($probability, $successes)) * (pow(1 - $probability, $failures));
          }
  
          return Functions::VALUE();
      }
docs: NEGBINOMDIST.
  
  Returns the negative binomial distribution. NEGBINOMDIST returns the probability that
  there will be number_f failures before the number_s-th success, when the constant
  probability of a success is probability_s. This function is similar to the binomial
  distribution, except that the number of successes is fixed, and the number of trials is
  variable. Like the binomial, trials are assumed to be independent.
  
  @param float $failures Number of Failures
  @param float $successes Threshold number of Successes
  @param float $probability Probability of success on each trial
  
  @return float