MathPHP\Statistics\Regression\PowerLaw::calculate PHP Method

calculate() public method

Calculate the regression parameters by least squares on linearized data ln(y) = ln(A) + B*ln(x)
public calculate ( )
    public function calculate()
    {
        // Linearize the relationship by taking the log of both sides.
        $x’ = array_map('log', $this->xs);
        $y’ = array_map('log', $this->ys);
        // Perform Least Squares Fit
        $linearized_parameters = $this->leastSquares($y’, $x’)->getColumn(0);
        // Translate the linearized parameters back.
        $this->a = exp($linearized_parameters[0]);
        $this->b = $linearized_parameters[1];
        $this->parameters = [$this->a, $this->b];
    }
PowerLaw