MathPHP\Functions\Map\Single::pow PHP Метод

pow() публичный статический Метод

Map raise to a power
public static pow ( array $xs, $n ) : array
$xs array
Результат array
    public static function pow(array $xs, $n) : array
    {
        return array_map(function ($x) use($n) {
            return $x ** $n;
        }, $xs);
    }

Usage Example

Пример #1
0
 /**
  * Calculate the regression parameters by least squares on linearized data
  * y⁻¹ = K * V⁻¹ * x⁻¹ + V⁻¹
  */
 public function calculate()
 {
     // Linearize the relationship by taking the inverse of both x and y
     $x’ = Single::pow($this->xs, -1);
     $y’ = Single::pow($this->ys, -1);
     // Perform Least Squares Fit
     $linearized_parameters = $this->leastSquares($y’, $x’)->getColumn(0);
     // Translate the linearized parameters back.
     $V = 1 / $linearized_parameters[0];
     $K = $linearized_parameters[1] * $V;
     $this->parameters = [$V, $K];
 }
All Usage Examples Of MathPHP\Functions\Map\Single::pow