original_string: public static function covarianceMatrix(array $data, ?array $means = null): array
      {
          $n = count($data[0]);
  
          if ($means === null) {
              $means = [];
              for ($i = 0; $i < $n; ++$i) {
                  $means[] = Mean::arithmetic(array_column($data, $i));
              }
          }
  
          $cov = [];
          for ($i = 0; $i < $n; ++$i) {
              for ($k = 0; $k < $n; ++$k) {
                  if ($i > $k) {
                      $cov[$i][$k] = $cov[$k][$i];
                  } else {
                      $cov[$i][$k] = self::fromDataset(
                          $data,
                          $i,
                          $k,
                          true,
                          $means[$i],
                          $means[$k]
                      );
                  }
              }
          }
  
          return $cov;
      }
code: public static function covarianceMatrix(array $data, ?array $means = null): array
      {
          $n = count($data[0]);
  
          if ($means === null) {
              $means = [];
              for ($i = 0; $i < $n; ++$i) {
                  $means[] = Mean::arithmetic(array_column($data, $i));
              }
          }
  
          $cov = [];
          for ($i = 0; $i < $n; ++$i) {
              for ($k = 0; $k < $n; ++$k) {
                  if ($i > $k) {
                      $cov[$i][$k] = $cov[$k][$i];
                  } else {
                      $cov[$i][$k] = self::fromDataset(
                          $data,
                          $i,
                          $k,
                          true,
                          $means[$i],
                          $means[$k]
                      );
                  }
              }
          }
  
          return $cov;
      }
code_tokens: public static function covarianceMatrix ( array $ data , ? array $ means = null ) : array { $ n = count ( $ data [ 0 ] ) ; if ( $ means === null ) { $ means = [ ] ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { $ means [ ] = Mean :: arithmetic ( array_column ( $ data , $ i ) ) ; } } $ cov = [ ] ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { for ( $ k = 0 ; $ k < $ n ; ++ $ k ) { if ( $ i > $ k ) { $ cov [ $ i ] [ $ k ] = $ cov [ $ k ] [ $ i ] ; } else { $ cov [ $ i ] [ $ k ] = self :: fromDataset ( $ data , $ i , $ k , true , $ means [ $ i ] , $ means [ $ k ] ) ; } } } return $ cov ; }
docstring: Returns the covariance matrix of n-dimensional data
  
  @param array|null $means
docstring_tokens: Returns the covariance matrix of n - dimensional data