Home > General-Functions > Statistics > generate_observed_ARp.m

generate_observed_ARp

PURPOSE ^

% generate_observed_ARp: generates samples of autoregressive processes

SYNOPSIS ^

function [x,y,sigma_x,sigma_y] = generate_observed_ARp(N,p,q,sigma_e,sigma_n)

DESCRIPTION ^

% generate_observed_ARp: generates samples of autoregressive processes

 [x,y,sigma_x,sigma_y] = 
   generate_observed_ARp(N,p,q,sigma_e,sigma_n);
 
 N         = number of points
 p         = order of process
 q         = decay (abs(q) < 1)
 sigma_e   = process noise
 sigma_n   = observation noise

 x         = true sample
 y         = noisy sample
 sigma_x   = theoretical std. of x
 sigma_y   = theoretical std. of y

 Wolfgang Förstner 01/2015
 wfoerstn@uni-bonn.de

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% generate_observed_ARp: generates samples of autoregressive processes
0002 %
0003 % [x,y,sigma_x,sigma_y] =
0004 %   generate_observed_ARp(N,p,q,sigma_e,sigma_n);
0005 %
0006 % N         = number of points
0007 % p         = order of process
0008 % q         = decay (abs(q) < 1)
0009 % sigma_e   = process noise
0010 % sigma_n   = observation noise
0011 %
0012 % x         = true sample
0013 % y         = noisy sample
0014 % sigma_x   = theoretical std. of x
0015 % sigma_y   = theoretical std. of y
0016 %
0017 % Wolfgang Förstner 01/2015
0018 % wfoerstn@uni-bonn.de
0019 
0020 function [x,y,sigma_x,sigma_y] = generate_observed_ARp(N,p,q,sigma_e,sigma_n)
0021 
0022 % initiate sample
0023 x = zeros(N,1);
0024 y = zeros(N,1);
0025 
0026 % determine coefficients from polynomial
0027 c = poly(q*ones(1,p));        % p roots q -> polynomial coeff.
0028 a = -c(2:p+1)';               % coeff. of ARp = polynomial coeff.
0029 
0030 % theoretical std of x and y
0031 sigma_x = sigma_e/sqrt((1-q)^p);
0032 sigma_y = sqrt(sigma_x^2+sigma_n^2);
0033 
0034 % generate true and noisy sample
0035 for n=p+1:N
0036     x(n) = sum(a(1:p).*x(n-1:-1:n-p))+randn(1)*sigma_e;
0037     y(n) = x(n)+randn(1)*sigma_n;
0038 end
0039 
0040

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005