]> Creatis software - CreaPhase.git/blob - octave_packages/tsa-4.2.4/biacovf.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / tsa-4.2.4 / biacovf.m
1 function [BIACF,ACF,M1] = biacovf(Z,N);
2 % BiAutoCovariance function 
3 % [BiACF] = biacovf(Z,N);
4 %
5 % Input:        Z    Signal
6 %               N  # of coefficients
7 % Output:       BIACF bi-autocorrelation function (joint cumulant 3rd order
8 % Output:       ACF   covariance function (joint cumulant 2nd order)
9
10 %       $Id: biacovf.m 5090 2008-06-05 08:12:04Z schloegl $
11 %       Copyright (C) 1997, 1998, 2008 by Alois Schloegl <a.schloegl@ieee.org>
12 %
13 %    This program is free software: you can redistribute it and/or modify
14 %    it under the terms of the GNU General Public License as published by
15 %    the Free Software Foundation, either version 3 of the License, or
16 %    (at your option) any later version.
17 %
18 %    This program is distributed in the hope that it will be useful,
19 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
20 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 %    GNU General Public License for more details.
22 %
23 %    You should have received a copy of the GNU General Public License
24 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
26 ACF=zeros(1,N+1);
27 BIACF=zeros(N+1,N+1);
28
29 Z=Z(:);
30 M=size(Z,1);
31
32 M1=sum(Z)/M;
33 Z=Z-M1*ones(size(Z));
34
35 for K=0:N, 
36         tmp=Z(1:M-K).*Z(1+K:M);
37         ACF(K+1)=sum(tmp)/M;
38         for L = K:N,
39                 BIACF(K+1,L+1) = sum(tmp(1:M-L).*Z(1+L:M))/M;
40         end;
41 end;
42
43 BIACF=BIACF+BIACF'-diag(diag(BIACF));