yt = $yt; $this->moving_periode = $moving_periode; $this->next_periode = $next_periode; $this->hitung(); } function hitung() { $temp = []; $temp_ft = null; foreach ($this->yt as $key => $val) { $temp = array_slice($temp, -$this->moving_periode); if (count($temp) >= $this->moving_periode) { $this->ft[$key] = array_sum($temp) / count($temp); $temp_ft = $this->ft[$key]; $this->et[$key] = $this->yt[$key] - $this->ft[$key]; $this->et_square[$key] = $this->et[$key] * $this->et[$key]; $this->et_abs[$key] = abs($this->et[$key]); $this->et_yt[$key] = abs($this->et[$key] / $this->yt[$key]); } $temp[] = $val; } $this->error['MSE'] = array_sum($this->et_square) / count($this->et_square); $this->error['RMSE'] = sqrt($this->error['MSE']); $this->error['MAE'] = array_sum($this->et_abs) / count($this->et_abs); $this->error['MAPE'] = array_sum($this->et_yt) / count($this->et_yt); for ($a = 1; $a <= $this->next_periode; $a++) { $temp = array_slice($temp, -$this->moving_periode); $this->next_ft[$a] = array_sum($temp) / count($temp); $temp_ft = $this->next_ft[$a]; $temp[] = $temp_ft; } } }