Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. %%Assignment 2.2
  2.  
  3. %%Ex.1
  4. %%b
  5. rng(123);
  6. n=length(atlantic);
  7. mles = est_gumbel(atlantic) %creating estimates of parameters from datafile
  8. u = rand(n,1); % n uniform drawn between 0-1
  9. x = -mles(1)*log(-log(u)) + mles(2); % using inverse transform method to
  10. %create new "samples"
  11.  
  12. qqplot(x,atlantic)
  13.  
  14. %% c
  15. B = 10000;
  16. mles2 = zeros(B,2);
  17. rng(123)
  18. for i = 1:B %parametric bootstrap
  19. u = rand(n,1);
  20. x = -mles(1)*log(-log(u)) + mles(2); %same code as in b)
  21. mles2(i,:) = est_gumbel(x); % creating new parameters from the new sample
  22. end
  23. mles2 = sort(mles2);
  24. CI_beta = prctile(mles2(:,1),[2.5, 97.5]); %making percentile-confint
  25. CI_mu = prctile(mles2(:,2),[2.5, 97.5]);
  26.  
  27.  
  28. %% d
  29. high = zeros(B); %where we want to store the highest wave that could be recorded
  30. % during a 100 year
  31. rng(123)
  32. T = 3*14*100; % Times the wave occur "normally" under 100 years
  33.  
  34. high = -mles2(:,1)*log(-log(1-(1/T))) + mles(:,2); %u from b) & c) is switched to (1-(1/T))
  35. high_ci = prctile(high, [2.5,97.5]);
  36.  
  37. %% f
  38.  
  39. for i = 1:B %making a non-parametric bootsample
  40. samp = randsample(atlantic,n,true); %taking a randomsample with replacement
  41. mles3(i,:) = est_gumbel(samp); %calculating and storing parameter each time
  42. end
  43. histogram(mles3(:,1))
  44. histogram(mles3(:,2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement