From c0c0582462720ed597b00e116506570577614e89 Mon Sep 17 00:00:00 2001 From: shamikam Date: Tue, 7 Nov 2017 15:59:48 +0530 Subject: initial commit --- macros/arburg.sci~ | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 macros/arburg.sci~ (limited to 'macros/arburg.sci~') diff --git a/macros/arburg.sci~ b/macros/arburg.sci~ new file mode 100644 index 0000000..1ca6e01 --- /dev/null +++ b/macros/arburg.sci~ @@ -0,0 +1,55 @@ +function varargout = arburg( x, poles, criterion ) +//This function calculates coefficients of an autoregressive (AR) model of complex data. +//Calling Sequence +//a = arburg(x, poles) +//a = arburg(x, poles, criterion) +//[a, v] = arburg(...) +//[a, v, k] = arburg(...) +//Parameters +//x: vector of real or complex numbers, of length > 2 +//poles: positive integer value < length(x) - 2 +//criterion: string value, takes in "AKICc", "KIC", "AICc", "AIC" and "FPE", default it not using a model-selection criterion +//a, v, k: Output variables +//Description +//This is an Octave function. +//This function calculates coefficients of an autoregressive (AR) model of complex data x using the whitening lattice-filter method of Burg. +//The first argument is the data sampled. The second argument is the number of poles in the model (or limit in case a criterion is supplied). +//The third parameter takes in the criterion to limit the number of poles. The acceptable values are "AIC", "AKICc", "KIC", "AICc" which are based on information theory. +//Output variable a is a list of P+1 autoregression coefficients. +//Output variable v is the mean square of residual noise from the whitening operation of the Burg lattice filter. +//Output variable k corresponds to the reflection coefficients defining the lattice-filter embodiment of the model. +//Examples +//arburg([1,2,3,4,5],2) +//ans = +// 1.00000 -1.86391 0.95710 + +funcprot(0); +rhs = argn(2) +lhs = argn(1) +if(lhs>3) +error("Wrong number of output arguments.") +elseif(rhs<2) +error("Wrong number of input arguments.") +end + + select(lhs) + case 1 then + if(rhs==2) + a = callOctave("arburg",x,poles) + elseif(rhs==3) + a = callOctave("arburg",x,poles,criterion) + end + case 2 then + if(rhs==2) + [a,v] = callOctave("arburg",x,poles) + elseif(rhs==3) + [a,v] = callOctave("arburg",x,poles,criterion) + end + case 3 then + if(rhs==2) + [a,v,k] = callOctave("arburg",x,poles) + elseif(rhs==3) + [a,v,k] = callOctave("arburg",x,poles,criterion) + end + end +endfunction -- cgit