Code covered by the BSD License  

Highlights from
value computer

value computer

by

 

value computer

value.m
function [vm] = value(t,x)
%UNTITLED1 Summary of this function goes here
%  Detailed explanation goes here
%vmΪ󷵻صֵ
%ֵ
%ȫֱ
global gama
global delta
global b
global tmax
global p
global y
global r
global rnormal
global valuemax
global alfamax
global cmax
num=100
if t==tmax
  num=100
    %Ϊڼֵ
   valuemax(t)=0
   for i=0:1/num:1
      for j=0:1/num:1      
          alfa1=j
          c1=i*(x+y(t))
          d=(x+y(t)-c1)*(1+alfa1*r(t)+(1-alfa1)*rnormal)
          value1=(c1^(1-gama)/(1-gama)+b*d^(1-gama)/(1-gama)) % ڵļֵ,dΪ
        if(value1>=valuemax(t))
            vm=value1
            valuemax(t)=value1
            alfamax(t)=alfa1
            cmax(t)=c1
        else
            vm=valuemax(t)
        end
       end
   end

else t<tmax %Ϊǰֵ
   valuemax(t)=0
   for l=0:1/num:1
      for k=0:1/num:1      
          alfa1=l
          c1=(x+y(t))*k
          d=(x+y(t)-c1)*(alfa1*r(t)+(1-alfa1)*rnormal)
          x1=(x+y(t)-c1)*(alfa1*r(t)+(1-alfa1)*rnormal)
          %ʽΪ㡣
          vn=value(t+1, x1)
          value= c1^(1-gama)/(1-gama)+delta*p(t)*vn+(1-p(t))*d^(1-gama)/(1-gama)
          % %ǰļֵĵʽc(t)^(1-gama)/(1-gama)ΪЧ
          %value(t+1, X(t+1))Ϊõ
          %b*(1-p(t))*d^(1-gama)/(1-gama)ΪЧ
          if(value>=valuemax(t))
              vm=value
              valuemax(t)=value
              alfamax(t)=alfa1
              cmax(t)=c1
          end
       end
    end
end

Contact us