code: public static function BETAINV($probability, $alpha, $beta, $rMin = 0, $rMax = 1)
      {
          $probability = Functions::flattenSingleValue($probability);
          $alpha = Functions::flattenSingleValue($alpha);
          $beta = Functions::flattenSingleValue($beta);
          $rMin = Functions::flattenSingleValue($rMin);
          $rMax = Functions::flattenSingleValue($rMax);
  
          if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
              if (($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax) || ($probability <= 0) || ($probability > 1)) {
                  return Functions::NAN();
              }
              if ($rMin > $rMax) {
                  $tmp = $rMin;
                  $rMin = $rMax;
                  $rMax = $tmp;
              }
              $a = 0;
              $b = 2;
  
              $i = 0;
              while ((($b - $a) > Functions::PRECISION) && ($i++ < self::MAX_ITERATIONS)) {
                  $guess = ($a + $b) / 2;
                  $result = self::BETADIST($guess, $alpha, $beta);
                  if (($result == $probability) || ($result == 0)) {
                      $b = $a;
                  } elseif ($result > $probability) {
                      $b = $guess;
                  } else {
                      $a = $guess;
                  }
              }
              if ($i == self::MAX_ITERATIONS) {
                  return Functions::NA();
              }
  
              return round($rMin + $guess * ($rMax - $rMin), 12);
          }
  
          return Functions::VALUE();
      }
docs: BETAINV.
  
  Returns the inverse of the beta distribution.
  
  @param float $probability Probability at which you want to evaluate the distribution
  @param float $alpha Parameter to the distribution
  @param float $beta Parameter to the distribution
  @param float $rMin Minimum value
  @param float $rMax Maximum value
  
  @return float