高教社杯2007年A题--Leslie算法,matlab实现

%人口分布向量
%性别l(l=m男性,l=w女性)
%地区j(j=1市镇,j=2农村,若单算市和镇,则j=1市,j=2镇,j=3乡)
%人口数量x(X-全国总人口,x-抽样总人口)
Xm1_2005=((VarName2_2005*4707903*0.01+VarName6_2005*2908980*0.01)/16985767)*1307560000;%城市男性人口
%4707903 城市抽样总人口 2908980 镇抽样总人口 16985767 抽样总人口 1307560000 总人口
Xm2_2005=((VarName10_2005*9368884*0.01)/16985767)*1307560000;%9368884 乡抽样总人口
Xw1_2005=((VarName4_2005*4707903*0.01+VarName8_2005*2908980*0.01)/16985767)*1307560000;
Xw2_2005=((VarName12_2005*9368884*0.01)/16985767)*1307560000;

xm1_2005=VarName2_2005*4707903*0.01;%4707903 市抽样总人口 得到市男性抽样人口
xm2_2005=VarName6_2005*2908980*0.01;%2908980 镇抽样总人口
xm3_2005=VarName10_2005*9368884*0.01;%9368884 乡抽样总人口
xw1_2005=VarName4_2005*4707903*0.01;%城市女性抽样人口数
xw2_2005=VarName8_2005*2908980*0.01;
xw3_2005=VarName12_2005*9368884*0.01;

xm1_2004=VarName2_2004*323576*0.01;%323576 城市抽样总人口
xm2_2004=VarName6_2004*192423*0.01;%192423 镇抽样总人口
xm3_2004=VarName10_2004*737066*0.01;%737066 乡抽样总人口
xw1_2004=VarName4_2004*323576*0.01;
xw2_2004=VarName8_2004*192423*0.01;
xw3_2004=VarName12_2004*737066*0.01;

xm1_2003=VarName2_2003*327947*0.01;%327947 城市抽样总人口
xm2_2003=VarName6_2003*191825*0.01;%191825 镇抽样总人口
xm3_2003=VarName10_2003*740726*0.01;%740726 乡抽样总人口
xw1_2003=VarName4_2003*323576*0.01;
xw2_2003=VarName8_2003*192423*0.01;
xw3_2003=VarName12_2003*740726*0.01;

xm1_2002=VarName2_2002*329381*0.01;%329381 城市抽样总人口
xm2_2002=VarName6_2002*157955*0.01;%157955 镇抽样总人口
xm3_2002=VarName10_2002*771615*0.01;%771615 乡抽样总人口
xw1_2002=VarName4_2002*329381*0.01;
xw2_2002=VarName8_2002*157955*0.01;
xw3_2002=VarName12_2002*771615*0.01;

xm1_2001=VarName2_2001*295372*0.01;%295372 城市抽样总人口
xm2_2001=VarName6_2001*158255*0.01;%158255 镇抽样总人口
xm3_2001=VarName10_2001*766932*0.01;%766932 乡抽样总人口
xw1_2001=VarName4_2001*295372*0.01;
xw2_2001=VarName8_2001*158255*0.01;
xw3_2001=VarName12_2001*766932*0.01;

dm1_2005=(VarName3_2005*xm1_2005'+VarName7_2005*xm2_2005')/16985767;
%2005年城市男性死亡率=(死亡率*对应年纪市男性数量+镇)/总人数
dm1_2004=(VarName3_2004*xm1_2004'+VarName7_2005*xm2_2004')/1253065;
dm1_2003=(VarName3_2003*xm1_2003'+VarName7_2005*xm2_2003')/1260498;
dm1_2002=(VarName3_2002*xm1_2002'+VarName7_2005*xm2_2002')/1258951;
dm1_2001=(VarName3_2001*xm1_2001'+VarName7_2005*xm2_2001')/1220559;
dm1_equ=(dm1_2005+dm1_2004+dm1_2003+dm1_2002+dm1_2001)/5;

dm1=zeros(91,1);%死亡率
i=1;
while(i<92)
    dm1(i,1)=dm1_equ(i,i);
    i=i+1;
end

Sm1=zeros(91);
i=2;
while(i<=91)
    Sm1(i,i-1)=1000-dm1(i-1,1);
    i=i+1;
end
sm1=zeros(91);
sm1(1,1)=1000;
%Sm1(91,90)=Sm1(91,90)-dm1(91,1);%存疑

dm2_2005=VarName11_2005*xm3_2005'/16985767;
dm2_2004=VarName11_2004*xm3_2004'/1253065;
dm2_2003=VarName11_2003*xm3_2003'/1260498;
dm2_2002=VarName11_2002*xm3_2002'/1258951;
dm2_2001=VarName11_2001*xm3_2001'/1220559;
dm2_equ=(dm2_2005+dm2_2004+dm2_2003+dm2_2002+dm2_2001)/5;

dm2=zeros(91,1);
i=1;
while(i<92)
    dm2(i,1)=dm2_equ(i,i);
    i=i+1;
end

Sm2=zeros(91);
i=2;
while(i<=91)
    Sm2(i,i-1)=1000-dm2(i-1,1);
    i=i+1;
end
sm2=zeros(91);
sm2(1,1)=1000;

dw1_2005=(VarName5_2005*xw1_2005'+VarName9_2005*xw2_2005')/16985767;
dw1_2004=(VarName5_2004*xw1_2004'+VarName9_2004*xw2_2004')/1253065;
dw1_2003=(VarName5_2003*xw1_2003'+VarName9_2003*xw2_2003')/1260498;
dw1_2002=(VarName5_2002*xw1_2002'+VarName9_2002*xw2_2002')/1258951;
dw1_2001=(VarName5_2001*xw1_2001'+VarName9_2001*xw2_2001')/1220559;
dw1_equ=(dw1_2005+dw1_2004+dw1_2003+dw1_2002+dw1_2001)/5;

dw1=zeros(91,1);
i=1;
while(i<92)
    dw1(i,1)=dw1_equ(i,i);
    i=i+1;
end

Sw1=zeros(91);
i=2;
while(i<=91)
    Sw1(i,i-1)=1000-dw1(i-1,1);
    i=i+1;
end
sw1=zeros(91);
sw1(1,1)=1000;

dw2_2005=VarName13_2005*xw3_2005'/16985767;
dw2_2004=VarName13_2004*xw3_2004'/1253065;
dw2_2003=VarName13_2003*xw3_2003'/1260498;
dw2_2002=VarName13_2002*xw3_2002'/1258951;
dw2_2001=VarName13_2001*xw2_2001'/1220559;
dw2_equ=(dw2_2005+dw2_2004+dw2_2003+dw2_2002+dw2_2001)/5;

dw2=zeros(91,1);
i=1;
while(i<92)
    dw2(i,1)=dw2_equ(i,i);
    i=i+1;
end

Sw2=zeros(91);
i=2;
while(i<=91)
    Sw2(i,i-1)=1000-dw2(i-1,1);
    i=i+1;
end
sw2=zeros(91);
sw2(1,1)=1000;

%2005年20岁城市生育子女的妇女占20岁城市妇女总人口的29.01‰
%假设一胎一个孩子
bw1_2005=((VarName15_2005.*xw1_2005+VarName16_2005.*xw2_2005)./(xw1_2005+xw2_2005))/1000;
%城市每位女性相应年纪生育孩子数=市女性生育几率*相应年纪抽样女性人口数/抽样总女性人口数
bw1_2004=((VarName15_2004.*xw1_2004+VarName16_2004.*xw2_2004)./(xw1_2004+xw2_2004))/1000;
bw1_2003=((VarName15_2003.*xw1_2003+VarName16_2003.*xw2_2003)./(xw1_2003+xw2_2003))/1000;
bw1_2002=((VarName15_2002.*xw1_2002+VarName16_2002.*xw2_2002)./(xw1_2002+xw2_2002))/1000;
bw1_2001=((VarName15_2001.*xw1_2001+VarName16_2001.*xw2_2001)./(xw1_2001+xw2_2001))/1000;
bw1_equ=(bw1_2005+bw1_2004+bw1_2003+bw1_2002+bw1_2001)/5;

Bw1_sum=sum(bw1_equ);%总和生育率

bw2_2005=VarName17_2005/1000;
bw2_2004=VarName17_2004/1000;
bw2_2003=VarName17_2003/1000;
bw2_2002=VarName17_2002/1000;
bw2_2001=VarName17_2001/1000;
bw2_equ=(bw2_2005+bw2_2004+bw2_2003+bw2_2002+bw2_2001)/5;

Bw2_sum=sum(bw2_equ);

a_2005=7616883/16985767;
a_2004=515999/1253065;
a_2003=519772/1260498;
a_2002=487336/1258951;
a_2001=453627/1220559;

x=[2001;2002;2003;2004;2005];
y=[a_2001;a_2002;a_2003;a_2004;a_2005];
%经拟合 y=0.01781*x-35.26715;
%假设迁移时按照2005农村人口比例

vm1=0.01781*VarName10_2005*13075600;
vw1=0.01781*VarName12_2005*13075600;
vm2=-vm1;
vw2=-vw1;

hw1_1=bw1_equ/Bw1_sum;%生育模式
hw2_1=bw2_equ/Bw2_sum;
%与题目所给数据存在两倍关系,请知道原因者评论告知
hw1_2=hw1_1*0.9/Bw1_sum;%长期生育模式
hw2_2=hw2_1*0.9/Bw2_sum;

Hw1_1=zeros(91);
Hw2_1=zeros(91);
Hw1_2=zeros(91);
Hw2_2=zeros(91);

i=10;
while(i<=50)%育龄区间
    Hw1_1(1,i)=hw1_1(i,1);
    Hw2_1(1,i)=hw2_1(i,1);
    Hw1_2(1,i)=hw1_2(i,1);
    Hw2_2(1,i)=hw2_2(i,1);
    i=i+1;
end


Xm1_ago=Xm1_2005;
Xw1_ago=Xw1_2005;
Xm2_ago=Xm2_2005;
Xw2_ago=Xw2_2005;

%长期预测
i=1;
Sum=zeros(20,1);
while(i<=20)  
    xm1_next=Sm1*Xm1_ago/1000+sm1*(114.8804167/214.8804167)*Bw1_sum*Hw1_2*Xw1_ago/1000+vm1;
    %114.8804167城市100个女生对应男生
    xw1_next=Sw1*Xw1_ago/1000+sm1*(100/214.8804167)*Bw1_sum*Hw1_2*Xw1_ago/1000+vw1;
    xm2_next=Sm2*Xm2_ago/1000+sm2*(119.6483333/219.6483333)*Bw2_sum*Hw2_2*Xw2_ago/1000+vm2;
    xw2_next=Sw2*Xw2_ago/1000+sw2*(100/219.6483333)*Bw2_sum*Hw2_2*Xw2_ago/1000+vw2;
    
    Xm1_ago=xm1_next;
    Xw1_ago=xw1_next;
    Xm2_ago=xm2_next;
    Xw2_ago=xw2_next;
    Sum(i,1)=sum(Xm1_ago)+sum(Xm2_ago)+sum(Xw2_ago)+sum(Xw1_ago);
    i=i+1;
end
%短期预测
i=1;
Sum=zeros(8,1);
while(i<=8)  
    xm1_next=Sm1*Xm1_ago/1000+sm1*(114.8804167/214.8804167)*Bw1_sum*Hw1_1*Xw1_ago/1000+vm1;
    %114.8804167城市100个女生对应男生
    xw1_next=Sw1*Xw1_ago/1000+sm1*(100/214.8804167)*Bw1_sum*Hw1_1*Xw1_ago/1000+vw1;
    xm2_next=Sm2*Xm2_ago/1000+sm2*(119.6483333/219.6483333)*Bw2_sum*Hw2_1*Xw2_ago/1000+vm2;
    xw2_next=Sw2*Xw2_ago/1000+sw2*(100/219.6483333)*Bw2_sum*Hw2_1*Xw2_ago/1000+vw2;
    
    Xm1_ago=xm1_next;
    Xw1_ago=xw1_next;
    Xm2_ago=xm2_next;
    Xw2_ago=xw2_next;
    Sum(i,1)=sum(Xm1_ago)+sum(Xm2_ago)+sum(Xw2_ago)+sum(Xw1_ago);
    i=i+1;
end

预测结果将存储在Sum中。

有改进意见请评论。

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值