code: public static function CHIDIST($value, $degrees)
      {
          $value = Functions::flattenSingleValue($value);
          $degrees = floor(Functions::flattenSingleValue($degrees));
  
          if ((is_numeric($value)) && (is_numeric($degrees))) {
              if ($degrees < 1) {
                  return Functions::NAN();
              }
              if ($value < 0) {
                  if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
                      return 1;
                  }
  
                  return Functions::NAN();
              }
  
              return 1 - (self::incompleteGamma($degrees / 2, $value / 2) / self::gamma($degrees / 2));
          }
  
          return Functions::VALUE();
      }
docs: CHIDIST.
  
  Returns the one-tailed probability of the chi-squared distribution.
  
  @param float $value Value for the function
  @param float $degrees degrees of freedom
  
  @return float