Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %%Assignment 2.2
- %%Ex.1
- %%b
- rng(123);
- n=length(atlantic);
- mles = est_gumbel(atlantic) %creating estimates of parameters from datafile
- u = rand(n,1); % n uniform drawn between 0-1
- x = -mles(1)*log(-log(u)) + mles(2); % using inverse transform method to
- %create new "samples"
- qqplot(x,atlantic)
- %% c
- B = 10000;
- mles2 = zeros(B,2);
- rng(123)
- for i = 1:B %parametric bootstrap
- u = rand(n,1);
- x = -mles(1)*log(-log(u)) + mles(2); %same code as in b)
- mles2(i,:) = est_gumbel(x); % creating new parameters from the new sample
- end
- mles2 = sort(mles2);
- CI_beta = prctile(mles2(:,1),[2.5, 97.5]); %making percentile-confint
- CI_mu = prctile(mles2(:,2),[2.5, 97.5]);
- %% d
- high = zeros(B); %where we want to store the highest wave that could be recorded
- % during a 100 year
- rng(123)
- T = 3*14*100; % Times the wave occur "normally" under 100 years
- high = -mles2(:,1)*log(-log(1-(1/T))) + mles(:,2); %u from b) & c) is switched to (1-(1/T))
- high_ci = prctile(high, [2.5,97.5]);
- %% f
- for i = 1:B %making a non-parametric bootsample
- samp = randsample(atlantic,n,true); %taking a randomsample with replacement
- mles3(i,:) = est_gumbel(samp); %calculating and storing parameter each time
- end
- histogram(mles3(:,1))
- histogram(mles3(:,2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement