-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.m
41 lines (34 loc) · 1012 Bytes
/
bootstrap.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
%turn off graph and count in ConstructPDF before you run this
for i=1:NEstimates,
EstID(i) = i;
end
EstID = EstID';
NBootstrap = 1000;
BootstrapPDF = JointPDF(:,1);
BWeight = zeros(NEstimates,NBootstrap);
for i=1:NBootstrap,
BID = datasample(EstID,NEstimates);
for j=1:NEstimates,
BWeight(j,i) = sum(BID==j);
end
end
NFilterSave = NFilter;
NFilter = 1;
JointCDFSave = JointCDF;
JointPDFSave = JointPDF;
clear JointCDF JointPDF
for i=1:NBootstrap;
display(i)
TotalWeight = TotalWeightSave.*BWeight(:,i);
ConstructPDF;
BootstrapPDF = [BootstrapPDF JointPDF];
end
%%
mx = prctile(BootstrapPDF',97.5);
mn = prctile(BootstrapPDF',2.5);
%plot(SCCgrid,sum(BootstrapPDF(:,2:end),2)/NBootstrap,SCCgrid,mn,SCCgrid,mx);
jbfill(SCCgrid(301:2101),mx(301:2101),mn(301:2101),'red','red',0)
hold on
plot(SCCgrid(301:2101),sum(BootstrapPDF((301:2101),2:end),2)/NBootstrap);
xlabel('dollar per tonne of carbon')
ylabel('Probability density')