Hi everyone,
Does anyone can tell me what's wrong with my code? I always receives the warnings:
Warning: Infinite or Not-a-Number value encountered.
U = 14; L = 7; d = (U-L)/2;d_star = d;T = ( U+L )/(1+1); % symmeric
alpha = 0.10;Le = 0.05;for kursi = [0 0.25 0.5 1 2 3] sigma = fzero( @(sigma) Le - (sigma./d)^2 - ( kursi.*sigma./d).^2, 1 ) ; mu = kursi*sigma + T; j = 1; for n = [25 50 100 150 200] delta = ( n.^(1/2) ).*kursi ; B = (n*d_star^2)/sigma^2; i= 1; for x = 7:0.01:14 sample = normrnd(mu,sigma,1,n);% fK = ( 2^(-(n-1)/2)/gamma((n-1)/2) ).*((B.*x.*(1-t)).^(n-3)/2 ).*exp(-B.*x.*(1-t)/2);
fun = @(t) ( sqrt( (B^3).*x./t )./2 ).*( ( 2^(-(n-1)/2) / gamma((n-1)/2) ).*( (B.*x.*(1-t)).^((n-3)/2) ).*exp(-B.*x.*(1-t)/2) ).*( normpdf(sqrt(B*x*T)+delta,0,1) + normpdf(sqrt(B*x*T)-delta,0,1) ); pdf_Lehat(j,i) = integral(@(t) fun(t),0,1); i = i + 1; end j = j + 1; end endx = 7:0.01:14;plot(x, pdf_Lehat(1,:)); hold onplot(x, pdf_Lehat(2,:)); hold onplot(x, pdf_Lehat(3,:)); hold onplot(x, pdf_Lehat(4,:)); hold onplot(x, pdf_Lehat(5,:)); hold onxlabel('X')
I guess the problem may be the handle ,fun, especially the mid part of the code (i.e. the above code, fK). Hope you can give me some advice, thanks!
Best Answer