public function approximate() { $correlation = $this->getCorrelation(); $step = $this->getStep(); $this->_tau = 0; for ($i = 0; $i < count($correlation); $i++) { if ($correlation[$i] < 0) { $p1 = new Model_Coordinate($step * ($i - 1), $correlation[$i - 1]); $p2 = new Model_Coordinate($step * $i, $correlation[$i]); $k = ($p2->getY() - $p1->getY()) / ($p2->getX() - $p1->getX()); $b = $p2->getY() - $k * $p2->getX(); $this->_tau = -$b / $k; break; } } $this->_beta = pi() / (2 * $this->_tau); $s1 = 0; $s2 = 0; for ($i = 0; $i * $step < $this->_tau; $i++) { $tau = $i * $step; $ro_tau = $correlation[$i]; $s1 += abs($tau * log($ro_tau / cos($this->_beta * $tau))); $s2 += $tau * $tau; } if ($this->_tau < $step) { $this->_alpha = 1; } else { $this->_alpha = $s1 / $s2; } }
private function getIntervalPoints($x) { $p1 = new Model_Coordinate(0, 0); $p2 = new Model_Coordinate(0, 0); foreach ($this->_coordinates as $item) { if ($x >= $p2->getX() && $p2) { $p1 = $p2; $p2 = $item; // $p2 = next( $this->_coordinates ); } } return array($p1, $p2); }