original_string: public static function fromXYArrays(array $x, array $y, $sample = true, float $meanX = null, float $meanY = null)
      {
          if (empty($x) || empty($y)) {
              throw InvalidArgumentException::arrayCantBeEmpty();
          }
  
          $n = count($x);
          if ($sample && $n === 1) {
              throw InvalidArgumentException::arraySizeToSmall(2);
          }
  
          if ($meanX === null) {
              $meanX = Mean::arithmetic($x);
          }
  
          if ($meanY === null) {
              $meanY = Mean::arithmetic($y);
          }
  
          $sum = 0.0;
          foreach ($x as $index => $xi) {
              $yi = $y[$index];
              $sum += ($xi - $meanX) * ($yi - $meanY);
          }
  
          if ($sample) {
              --$n;
          }
  
          return $sum / $n;
      }
code: public static function fromXYArrays(array $x, array $y, $sample = true, float $meanX = null, float $meanY = null)
      {
          if (empty($x) || empty($y)) {
              throw InvalidArgumentException::arrayCantBeEmpty();
          }
  
          $n = count($x);
          if ($sample && $n === 1) {
              throw InvalidArgumentException::arraySizeToSmall(2);
          }
  
          if ($meanX === null) {
              $meanX = Mean::arithmetic($x);
          }
  
          if ($meanY === null) {
              $meanY = Mean::arithmetic($y);
          }
  
          $sum = 0.0;
          foreach ($x as $index => $xi) {
              $yi = $y[$index];
              $sum += ($xi - $meanX) * ($yi - $meanY);
          }
  
          if ($sample) {
              --$n;
          }
  
          return $sum / $n;
      }
code_tokens: public static function fromXYArrays ( array $ x , array $ y , $ sample = true , float $ meanX = null , float $ meanY = null ) { if ( empty ( $ x ) || empty ( $ y ) ) { throw InvalidArgumentException :: arrayCantBeEmpty ( ) ; } $ n = count ( $ x ) ; if ( $ sample && $ n === 1 ) { throw InvalidArgumentException :: arraySizeToSmall ( 2 ) ; } if ( $ meanX === null ) { $ meanX = Mean :: arithmetic ( $ x ) ; } if ( $ meanY === null ) { $ meanY = Mean :: arithmetic ( $ y ) ; } $ sum = 0.0 ; foreach ( $ x as $ index => $ xi ) { $ yi = $ y [ $ index ] ; $ sum += ( $ xi - $ meanX ) * ( $ yi - $ meanY ) ; } if ( $ sample ) { -- $ n ; } return $ sum / $ n ; }
docstring: Calculates covariance from two given arrays, x and y, respectively
  
  @param array $x
  @param array $y
  @param bool  $sample
  @param float $meanX
  @param float $meanY
  
  @return float
  
  @throws InvalidArgumentException
docstring_tokens: Calculates covariance from two given arrays x and y respectively