Guest User

Untitled

a guest
Dec 27th, 2015
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. close all
  3. clear all
  4.  
  5.  
  6. T = 10000;
  7. mu =2 ;
  8. sigma = 0.4 ;
  9.  
  10.  
  11. x = (randn(T,1)* sigma) +mu ; %% X distributed (mean = mu and std = sigma)
  12. Z = (x -mu)./sigma ;
  13. xPos = 1.5;
  14.  
  15.  
  16. figure
  17. subplot(4,2,1)
  18. hist(x)
  19. title('a) X')
  20. subplot(4,2,2)
  21. hist(Z)
  22. title('b) Z')
  23.  
  24.  
  25.  
  26. subplot(4,2,3)
  27. xsort = sort(x);
  28. PDF_X = normpdf(xsort,mu,sigma );
  29. plot(xsort,PDF_X)
  30. title(strcat('c) pdf(X), integral =',num2str( trapz(xsort,PDF_X))))
  31. hold on
  32. y1=get(gca,'ylim');
  33. plot([xPos xPos],y1);
  34. hold off
  35.  
  36.  
  37. subplot(4,2,4)
  38. zsort = sort(Z);
  39. PDF_Z = normpdf(zsort,0,1 );
  40. plot(zsort,PDF_Z)
  41. title(strcat('d) pdf(Z), integral =',num2str(trapz(zsort,PDF_Z))))
  42. hold on
  43. y1=get(gca,'ylim');
  44. plot([xPos xPos],y1);
  45. hold off
  46.  
  47.  
  48. subplot(4,2,5)
  49.  
  50. plot(xsort,PDF_Z)
  51. title(strcat('e) pdf(Z) wrong domain, integral =',num2str(trapz(xsort,PDF_Z))))
  52. hold on
  53. y1=get(gca,'ylim');
  54. plot([xPos xPos],y1);
  55. hold off
  56.  
  57.  
  58. subplot(4,2,7)
  59. PDF3 = PDF_Z./sigma ;
  60. plot(xsort,PDF3)
  61. title(strcat('f) pdf(Z)/sigma, integral =',num2str(trapz(xsort,PDF3))))
  62. hold on
  63. y1=get(gca,'ylim');
  64. plot([xPos xPos],y1);
  65. hold off
RAW Paste Data