声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3598|回复: 10

[分形与混沌] c-c求tau出现的问题?

[复制链接]
发表于 2007-10-21 20:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
function [s,delt_s,s_cor]=C_CMethod(data)
%this function calculate time delay and embedding demension with C-C
% 该函数用C-C算法来计算延迟时间和嵌入维数
%Method,which proved by H.S.Kim
%skyhawk&flyinghawk
% %****************调试程序段****************************
% clear all;
% data=load('f:/sunpot/year sunpot number.txt');
% %************************************************
N=length(data);                                     % 数据向量长度
max_d=20;    %the maximum value of the time delay     时间延迟的最大值
sigma=std(data);%calcute standard deviation s_d       计算标准偏差s_d
for t=1:max_d
    t
    s_t=0;
    delt_s_s=0;
    for m=2:5
        s_t1=0;
        for j=1:4
            r=sigma*j/2;
            data_d=disjoint(data,N,t);            %将时间序列分解成t个不相交的时间序列
            [ll,N_d]=size(data_d);
            s_t3=0;
            for i=1:t
                i
                Y=data_d(i,:);
                C_1(i)=correlation_integral(Y,N_d,r);            %计算C(1,N_d,r,t)
                X=reconstitution(Y,N_d,m,t);                     %相空间重构
                N_r=N_d-(m-1)*t;
                C_I(i)=correlation_integral(X,N_r,r);            %计算C(m,N_r,r,t)
                s_t3=s_t3+(C_I(i)-C_1(i)^m);                     %对t个不相关的时间序列求和
            end
            s_t2(j)=s_t3/t;
            s_t1=s_t1+s_t2(j);                                   %对rj求和
        end
        delt_s_m(m)=max(s_t2)-min(s_t2);                         %求delt S(m,t)
        delt_s_s=delt_s_s+delt_s_m(m);                           %delt S(m,t)对m求和
        s_t0(m)=s_t1;
        s_t=s_t+s_t0(m);                                         %S对m求和
    end
    s(t)=s_t/16;
    delt_s(t)=delt_s_s/4;
    s_cor(t)=delt_s(t)+abs(s(t));
   
end
fid=fopen('result.txt','w');
fprintf(fid,'%f %f %f %f/n',t,s(t),delt_s(t),s_cor(t));
fclose(fid);
t=1:max_d;
plot(t,s,t,delt_s,'.',t,s_cor,'*')
        


function C_I=correlation_integral(X,M,r)
%the function is used to calculate correlation integral
%C_I:the value of the correlation integral
%X:the reconstituted state space,M is a m*M matrix
%m:the embedding demention
%M:M is the number of embedded points in m-dimensional sapce
%r:the radius of the Heaviside function,sigma/2<r<2sigma
%calculate the sum of all the values of Heaviside
%skyhawk
sum_H=0;
for i=1:M
%     fprintf('%d/%d\n',i,M);
    for j=i+1:M
        d=norm((X(:,i)-X(:,j)),inf);%calculat the distances of each two points in matris M with sup-norm
        sita=heaviside(r,d);%calculate the value of the heaviside function
        sum_H=sum_H+sita;
    end
end
C_I=2*sum_H/(M*(M-1));%the value of correlation integral


function data_d=disjoint(data,N,t)
%the function is used to subdivid the time series into t disjoint time
%series.
%data:the time series
%N:the length of the time series
%t:the index lag
%skyhawk
for i=1:t
    for j=1:(N/t)
        data_d(i,j)=data(i+(j-1)*t);
    end
end

function sita=heaviside(r,d)
%the function is used to calculate the value of the Heaviside function
%sita:the value of the Heaviside function
%r:the radius in the Heaviside function,sigma/2<r<2sigma
%d:the distance of two points
%skyhawk
if (r-d)<0
    sita=0;
else sita=1;
end

function X=reconstitution(data,N,m,tau)
%该函数用来重构相空间
% m为嵌入空间维数
% tau为时间延迟
% data为输入时间序列
% N为时间序列长度
% X为输出,是m*n维矩阵
M=N-(m-1)*tau;%相空间中点的个数
for j=1:M           %相空间重构
    for i=1:m
        X(i,j)=data((i-1)*tau+j);
    end
end

这是我用到的程序,在此感谢oct和无水!
我输入一组数据,共700个!还有我另外输了论坛上的一组数据(共14个),出现的错误是一样的!如下:
??? Output argument "X" (and maybe others) not assigned during call to "C:\Program Files\MATLAB71\work\reconstitution.m (reconstitution)".
Error in ==> reconstitution at 9
M=N-(m-1)*tau;%相空间中点的个数
Error in ==> C_CMethod at 31
                X=reconstitution(Y,N_d,m,t);                     %相空间重构




700个数据时候,电脑运算后i=1, i=2一直到i=14
是不是tau就是14?
请高手们帮我解决?
回复
分享到:

使用道具 举报

 楼主| 发表于 2007-10-22 10:15 | 显示全部楼层

用Chaos Toolbox Ver.2.0的问题

用Chaos Toolbox Ver.2.0来算Lyapunov指数,我用的Wolf程序!可为什么得不到结果?出现的错误是
?? Output argument "X" (and maybe others) not assigned during call to "C:\Program Files\MATLAB71\work\Chaos Toolbox Ver.2.0\Main\reconstitution.m (reconstitution)".

Error in ==> reconstitution at 9
M=N-(m-1)*tau;%相空间中点的个数

Error in ==> lyapunov_wolf at 16
    Y=reconstitution(data,N,m,tau);                    %相空
版主们,高手们帮我解决啊?
发表于 2007-10-22 11:30 | 显示全部楼层

回复 #2 chyqingalan 的帖子

确实不好意思。最近比较忙。
你把数据也上传一份,有时间我调试一下吧,:@L
 楼主| 发表于 2007-10-22 13:26 | 显示全部楼层

数据 我的目的是计算Lyapunov指数

谢谢!我做了N次!总是有问题!
5.1350
5.1270
5.1300
5.1310
5.1440
5.1480
5.1500
5.1720
5.1795
5.1770
5.1840
5.1810
5.1790
5.1665
5.1900
5.1970
5.2210
5.2390
5.2450
5.2490
5.2880
5.2810
5.3075
5.2760
5.2950
5.2950
5.2950
5.2920
5.2915
5.3550
5.3315
5.3220
5.2975
5.2800
5.2845
5.2890
5.2890
5.3035
5.3370
5.3660
5.3710
5.3520
5.3620
5.3620
5.3420
5.3205
5.2980
5.3085
5.2920
5.2790
5.2690
5.2325
5.2460
5.2400
5.2680
5.2780
5.2790
5.2930
5.3000
5.2810
5.2870
5.2900
5.3040
5.3250
5.3410
5.3350
5.3315
5.3505
5.3540
5.3775
5.3695
5.3630
5.3810
5.3900
5.3925
5.3840
5.3690
5.3660
5.3690
5.3650
5.3640
5.3715
5.3710
5.3725
5.4030
5.4360
5.4260
5.4390
5.4200
5.4300
5.4425
5.4425
5.4790
5.4650
5.4480
5.4510
5.4440
5.4710
5.4675
5.4725
5.4840
5.4815
5.4705
5.4630
5.4745
5.4785
5.5400
5.5360
5.5290
5.5250
5.5150
5.5450
5.5365
5.4500
5.4680
5.5030
5.5320
5.5255
5.5175
5.4945
5.5055
5.5375
5.5450
5.5530
5.5500
5.5560
5.7365
5.5920
5.6225
5.6270
5.6830
5.6720
5.6730
5.7030
5.7060
5.7120
5.6750
5.7080
5.7300
5.7320
5.7310
5.7205
5.7260
5.7460
5.7725
5.7855
5.7870
5.7870
5.8250
5.9180
5.9350
5.9300
5.9350
5.9860
5.9750
5.9500
5.9500
5.9450
5.9375
5.9390
5.9650
5.9380
5.9150
5.9270
5.9750
5.9470
5.9520
5.9310
5.9300
5.9525
5.9420
5.9460
5.9440
5.9805
5.9930
6.0050
5.9975
5.9875
5.9930
5.9850
5.9900
5.9900
6.0050
6.0625
6.1130
6.1500
6.1050
6.1460
6.1200
6.1375
6.1550
6.0300
6.0300
6.0300
6.0250
6.0300
5.9900
6.0100
6.0150
6.0200
6.0300
5.9800
6.0100
5.9950
5.9880
5.9900
5.9380
5.8520
5.8825
5.8620
5.8620
5.8300
5.7230
5.6750
5.6770
5.6200
5.6600
5.6630
5.6475
5.6475
5.6750
5.6825
5.6625
5.6580
5.6530
5.6470
5.6425
5.6500
5.6125
5.6180
5.5075
5.5950
5.5875
5.5770
5.5750
5.5800
5.6350
5.6250
5.6325
5.6350
5.6380
5.6500
5.6675
5.6650
5.6625
5.6625
5.6750
5.6750
5.6825
5.6900
5.6875
5.6650
5.6950
5.7000
5.7300
5.7250
5.7605
5.7960
5.7780
5.8580
5.8530
5.8870
5.8180
5.8250
5.8200
5.8150
5.8850
5.8600
5.8200
5.8375
5.7900
5.8590
5.8600
5.8825
5.8575
5.8450
5.8550
5.8850
5.8850
5.8850
5.9250
5.9250
5.8930
5.8880
5.8925
5.9050
5.9030
5.9020
5.8950
5.8950
5.8800
5.8730
5.8630
5.8500
5.8350
5.8550
5.8060
5.7930
5.7790
5.7650
5.8130
5.7940
5.8100
5.8170
5.8380
5.8250
5.8130
5.8170
5.8260
5.8555
5.8410
5.8430
5.8230
5.8230
5.8320
5.8440
5.8360
5.8370
5.8370
5.8450
5.8280
5.8200
5.8270
5.8380
5.8280
5.8050
5.8050
5.8180
5.8370
5.8250
5.8320
5.8250
5.8120
5.8170
5.8160
5.8170
5.8100
5.7850
5.7630
5.7710
5.7650
5.7570
5.7670
5.7670
5.7300
5.7375
5.7270
5.7325
5.7100
5.7050
5.7380
5.7220
5.7310
5.7475
5.7770
5.7800
5.7650
5.7775
5.8250
5.8210
5.8375
5.8400
5.8270
5.8540
5.8800
5.8680
5.8860
5.9175
5.9690
5.9500
5.9410
5.8875
5.9100
5.9370
5.9200
5.9025
5.9075
5.8870
5.9105
5.9500
5.9400
5.8975
5.8675
5.8880
5.8985
5.8945
5.8940
5.8700
5.8985
5.8625
5.8760
5.8575
5.9110
5.9350
5.9300
5.9360
5.9405
5.9175
6.0200
6.0600
6.0450
6.0800
6.1590
6.1480
6.1200
6.1430
6.1050
6.1350
6.1500
6.0400
6.0560
6.0050
6.0250
5.9625
5.9800
5.9975
6.0350
6.0850
6.0475
6.0750
6.0625
6.0400
6.0600
6.0720
6.0800
6.1050
6.1880
6.0970
6.1180
6.1130
6.1195
6.1050
6.1200
6.1100
6.1250
6.1250
6.2050
6.2140
6.2125
6.2850
6.3500
6.5400
6.4700
6.4900
6.3600
6.3700
6.4600
6.5000
6.5000
6.5100
6.5375
6.5680
6.6400
6.7000
6.7100
6.8300
6.9400
6.8600
6.8700
6.8700
6.8300
6.6000
6.6900
6.6800
6.7600
6.6700
6.5700
6.6400
6.7000
6.7000
6.6500
6.6700
6.6400
6.6200
6.6800
6.6600
6.6900
6.6555
6.6700
6.6400
6.6300
6.5975
6.5850
6.5200
6.5300
6.5300
6.5300
6.6600
6.5200
6.5500
6.5300
6.5375
6.5400
6.5400
6.5300
6.5300
6.5300
6.5100
6.4800
6.4800
6.4800
6.4800
6.4900
6.5250
6.5150
6.5050
6.5090
6.5050
6.5175
6.5150
6.5025
6.5100
6.5100
6.5150
6.5200
6.5250
6.5250
6.5150
6.5950
6.5450
6.5650
6.5525
6.5675
6.5900
6.6240
6.5950
6.6150
6.6350
6.6130
6.6200
6.6070
6.6000
6.6000
6.5925
6.5925
6.6030
6.6025
6.5900
6.6100
6.6090
6.6000
6.6160
6.6175
6.6175
6.6130
6.6140
6.6125
6.6250
6.6275
6.6175
6.6170
6.6230
6.6275
6.6220
6.6300
6.6375
6.6950
6.6730
6.6825
6.6775
6.6850
6.7425
6.7350
6.7175
6.7225
6.7250
6.7175
6.7150
6.7090
6.7125
6.7200
6.7275
6.7350
6.7575
6.7625
6.7625
6.8350
6.8050
6.8550
6.8075
6.8200
6.8280
6.8750
6.8650
6.8825
6.9050
6.9600
6.9575
6.9125
6.8750
6.9000
6.8950
6.9100
6.8950
6.9140
6.9200
6.9550
6.9875
7.0000
7.0300
6.9000
7.0200
7.0800
6.9000
7.0650
7.0800
7.1450
7.2400
7.2500
7.2800
7.4600
7.6200
7.4700
7.4300
7.4700
7.4200
7.3900
7.4000
7.2300
7.1345
7.1345
7.1200
7.1200
7.1800
7.1600
7.1700
7.1800
7.2000
7.1500
7.1500
7.1500
7.1000
7.1300
7.1350
7.1510
7.1500
7.1600
7.1600
7.1600
7.1875
7.1825
7.1600
7.1350
7.1750
7.2100
7.2100
7.2000
7.2100
7.2400
7.3550
7.3400
7.3580
7.4600
7.5000
7.4950
7.4350
7.5000
7.4765
7.4500
7.4350
7.4400
7.3550
7.4075
7.4400
7.4200
7.4250
7.4400
7.4100
7.4600
7.4700
7.5400
7.5450
7.5675
7.6025
7.6450
7.7250
7.6700
7.6575
7.6700
7.8450
7.8525
7.8600
7.9800
8.4000
8.3000
8.1700
8.2500
8.7000
8.3500
8.4000
8.2500
8.1200
8.1500
8.7000
8.5200
8.6700
8.5400
8.4500
8.2700
8.2600
8.2300
8.1700
发表于 2007-10-22 14:03 | 显示全部楼层
无水,这个重构相空间函数,我以前用过没有问题的,怎么在这里会出现问题,我百思不得其解,你也看看吧!
发表于 2007-10-24 08:47 | 显示全部楼层
我之前也遇到了这样的问题,后来我找到了原因,因为C-C方法中要将时间序列分为t个子序列,尔后会对子序列分别进行相空间重构,因此,子序列的长度N—d是不能小于(m-1)*t,所以当数据为700个时,因此,这时就有700/t-(m-1)*t>0,又因m的最大值是5,所示t就应该是小于13的,也就是说t最大只能取12。
发表于 2007-10-24 08:59 | 显示全部楼层
那这个就属于方法中的问题了,你有没有什么办法修改一下?
发表于 2007-10-24 09:16 | 显示全部楼层
这我也不知道能不能算是方法的问题,只是我怀疑C-C方法对小数据量,也就是小于3000组的数据是否也一样有效呢?至于t的最大值的选取,我想肯定是与数据量的大小相关的。
发表于 2007-10-24 10:12 | 显示全部楼层
你说的也有一定的道理!我最近把关联维数搞定了就开始CC方法的研究,呵呵,一起学习吧!
发表于 2007-10-24 11:12 | 显示全部楼层
其实我也没太搞清楚关联维和CC方法!
发表于 2007-10-24 13:49 | 显示全部楼层

回复 #10 柏莱 的帖子

关联维数现在基本上快差不多了,CC马上开始,其实也没有那么难的,主要还是要把基础理论看懂啊!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 13:48 , Processed in 0.113903 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表