Home > wafo > wdemos > rfcdemo1 > discar.m

# discar

## PURPOSE

Discretizes an AR(1) process.

## SYNOPSIS

[P,uu] = discar(u,a1,m,s)

## DESCRIPTION

  DISCAR   Discretizes an AR(1) process.
System equation: X(k) = -a1*X(k-1) + e(k),  e(k) = N(m,s^2)

P = discar(u,a1,s,m)

P = Transition matrix,
P(i,j) = P ( u(j)<X(k)<u(j+1) |  u(i)<X(k-1)<u(i+1) )

u  = Discretization levels.
a1 = System parameter.
m  = Innovation mean.
s  = Innovation std.

## CROSS-REFERENCE INFORMATION

This function calls:
 quad8 Numerically evaluate integral, higher order method.
This function is called by:
 rfcdemo1 Demo for switching AR(1)-processes.

## SOURCE CODE

001 function [P,uu] = discar(u,a1,m,s)
002
003 % DISCAR   Discretizes an AR(1) process.
004 %     System equation: X(k) = -a1*X(k-1) + e(k),  e(k) = N(m,s^2)
005 %
006 % P = discar(u,a1,s,m)
007 %
008 % P = Transition matrix,
009 %     P(i,j) = P ( u(j)<X(k)<u(j+1) |  u(i)<X(k-1)<u(i+1) )
010 %
011 % u  = Discretization levels.
012 % a1 = System parameter.
013 % m  = Innovation mean.
014 % s  = Innovation std.
015
016 % Copyright (c) 1997 by Pär Johannesson
017 % Toolbox: Rainflow Cycles for Switching Processes V.1.0, 2-Oct-1997
018
019 n = length(u);
020 PP = zeros(n-1,n-1);
021 tol =2e-1;
022
023 for i = 1:n-1
024   fprintf(1,'   i = %d\n',i);
025
026   % P(i,j) = P ( u(j)<X(k)<u(j+1) ,  u(i)<X(k-1)<u(i+1) )
027   for j = 1:n-1
028     PP(i,j) = quad8('f_ar',u(i),u(i+1),tol,[],u(j),u(j+1),a1,m,s);
029   end
030
031   % Pi = P ( u(i)<X(k)<u(i+1) )
032 %  Pi = normcdf((u(i+1)-m)*sqrt(1-a1^2)/s)-normcdf((u(i)-m)*sqrt(1-a1^2)/s);
033
034   % P(i,j) = P ( u(j)<X(k)<u(j+1) |  u(i)<X(k-1)<u(i+1) )
035 %  if Pi == 0  % Prob. outside working precision
036 %    PP(i,:) = PP(i,:)/sum(PP(i,:));
037 %  else
038 %    PP(i,:) = PP(i,:)/Pi;
039 %  end
040 end
041
042 P = PP;
043 uu = (u(1:n-1)+u(2:n))/2;
044

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003