Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Program working on one PC but not on other
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
In a program to calculate value at risk. The for loop is stuck on a particular iteration 41 out of 50 iterations. But on some machines it is working fine.
Is there a problem of memory allocation or something else?
The error is coming is following function
function z2 = myfunction(r1,x1,x2)
warning('off', 'stats:gpfit:EvalLimit');
[bootstat,bootsam] = bootstrp(50,[],r1); %Sampling With Replacement from r1
Z=sort(r1(bootsam));% bootsam is the indices and Z1(bootsam) is 50 sample drawn
temp = [];
for k1 = x1:.1:x2
a5=0;
for i = 1:50
y5=Z(:,i);
[f12,x12]=ecdf(y5);
f12=f12(2:end);
x12=x12(2:end);
k11=k1;
k1 = min(k1,(y5(end-500))); % this is due to the possibility that the threshold could be greater than y(end-500)
% at least 500 observations are required to calculate Non-subjective Value-at-Risk
y5(y5<=k1)=[];
para = gpfit(y5-k1);
[h7, h8] = size (y5>k1);
h4=min(find(y5>k1));
[h5, h6] = size (y5);
s5=0;
clear F1 F2 F3 g;
for j5=h4:h5
F1=1-interp1q(x12,f12,y5(j5));
F2=1-interp1q(x12,f12,k1);
F3 = F1/F2;
g = 1-gpcdf(y5(j5)-k1,para(1), para(2), 0);
s5=s5+(g-F3)^2;
end
a5=a5+(s5/h7);
end
temp = [temp; [k1 a5]];
k1=k11;
end
[M,I]= min(temp(:,2));
z2=temp(I,1);
end
4 commentaires
Rik
le 3 Juil 2020
I don't see j6 anywhere in the code you posted, so the output is a bit strange. Did you try using breakpoints?
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!