Advertisement
makispaiktis

Tutorial Thomas - Randomness

Jul 24th, 2021 (edited)
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.67 KB | None | 0 0
  1. clc
  2. clear all
  3.  
  4. x = linspace(0, 4*pi, 1001);
  5. noise = randn(1, 1001);
  6. subplot(2,2,1);
  7. plot(x, noise);
  8. title('Random signal');
  9.  
  10. y = x + noise;              % y = x function with noise
  11. subplot(2,2,2);
  12. plot(x, y);
  13. title('y = x with the noise effect');
  14.  
  15. y2 = sin(x) + noise;
  16. subplot(2,2,3);
  17. plot(x, y2);
  18. title('y = sinx with the noise effect');
  19.  
  20. % For y3, I will add 30 normal distribution ----> Gaussian curve
  21. y3 = [];
  22. counter = 0;
  23. for i = 1:1001
  24.     counter = counter + 1;
  25.     value = 0;
  26.     for j = 1:30
  27.         value = value + randn();
  28.     end
  29.     y3(counter) = value;
  30. end
  31. subplot(2,2,4);
  32. spots = 20;
  33. hist(y3, spots);
  34. title('y =  Σ(30 normal distributions)');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement