Advertisement
makispaiktis

Tutorial - Measure probability

Aug 11th, 2021 (edited)
1,186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.57 KB | None | 0 0
  1. clc
  2. clear all
  3.  
  4. % I will load a 100x1 vector
  5. R = csvread('random_integers.csv');
  6. Length = length(R)
  7. display('Even numbers are: ');
  8. even = sum(mod(R, 2) == 0);
  9. disp(even);
  10. display('Odd numbers are: ');
  11. odd = sum(mod(R, 2) == 1);
  12. disp(odd);
  13. display('Probabilities are: ');
  14. probEven = even / Length;
  15. probOdd = odd / Length;
  16. disp([probEven, probOdd]);
  17.  
  18. display(' ');
  19. display('Fives and minus_fives: ');
  20. fives = sum(R == 5);
  21. minusFives = sum(R == -5);
  22. disp([fives, minusFives]);
  23. display('Probability in abs(5): ');
  24. abs5 = sum(abs(R) == 5) / Length;
  25. disp(abs5);
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement