1function [GAMMA, RHO0, RESIDUALS] = map_gamma(MAP, limit)
2% Estimates the
auto-correlation decay rate of a MAP.
3% For MAPs of order higher than 2, performs an approximation of the ACF
4% curve
using non-linear least squares fitting.
7% - limit: maximum lag considered (optional,
default = 1000)
9% - GAMMA: autocorrelation decay rate
13 lag = 1:(limit/10):limit;
17 error(
'Invalid parameter');
23 % poisson process: no correlation
26 % second-order MAP: geometric ACF
27 if abs(map_acf(MAP,1)) < 1e-8
31 GAMMA = map_acf(MAP,2) / map_acf(MAP,1);
34 % higher-order MAP: non-geometric
37 M2 = map_moment(MAP, 2);
40 RHO0 = 1/2 * (1 - 1/SCV);
42 rho = map_acf(MAP, lag)
';
44 %problem.Variables = 1;
47 %problem.ObjFunction = @(x) sum((geometric(x,lag)-rho).^2);
48 %GAMMA = PSwarm(problem);
50 opt = statset('nlinfit
');
53 opt.RobustWgtFun = 'fair
';
55 [GAMMA,RESIDUALS] = nlinfit(lag, rho, @geometric, 0.99, opt);
57 warning('Non linear regression
for ACF decay rate failed, trying lsqcurvefit
');
58 GAMMA = lsqcurvefit(@geometric, 0.99, lag, rho, -1, 1);
62 function rhok = geometric(gamma,k)
63 rhok = (RHO0 * gamma.^k)';