function [w_opt,S_n,et,MSE,omega_grid,MSE_omega] = double_exp_smoothing_optimum(Z,omega_grid) % DOUBLE_EXP_SMOOTHING_OPTIUM - Find the optimum relaxation coefficient to use with double exponential smoothing % % Inputs: % Z : the original sequence % omega_grid : the grid of possible omega values to search over (optional) % % Outputs: % w_opt : the optimal value of omega the relaxation coefficient % S_n : the optimal smoothed sequence of z_n % et : the optimal one step-ahead residuals % MSE : the optimal mean square error % omega_grid : the grid of omegas searched over (will be the same if passed in) % MSE_omega : the in-sample mean square error for each value of omega in omega_grid % % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- if( nargin<2 ) % a reasonable default for the grid of omegas to search over omega_grid = linspace(0.1,0.99,100); end MSE_omega = zeros(1,length(omega_grid)); for ii=1:length(omega_grid), [ Ys, S_1, S_2, et, MSE_omega(ii) ] = double_exp_smoothing( Z, omega_grid(ii) ); end [min_value,min_indx] = min( MSE_omega ); w_opt = omega_grid(min_indx); [ S_n, S_1, S_2, et, MSE ] = double_exp_smoothing( Z, w_opt );