Advertisement
Sri27119

hypergeometric and binomial comparison

May 19th, 2024
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.71 KB | None | 0 0
  1. % When population size is much larger than number of samples drawn n>>m
  2. x = 0:4;
  3. m= 300;
  4. k= 100;
  5. n= 4;
  6. Px= hygepdf(x,m,k,n);
  7. p= k/m;
  8. Px2= binopdf(x,n,p);
  9. plot(Px,'r');
  10. hold
  11. plot(Px2,'b');
  12. title('WHEN POPULATION SIZE IS MUCH LARGER THAN SAMPLE');
  13. legend('Hypergeometric','Binomial');
  14. xlabel('Number of samples --->');
  15. ylabel('Probability --->');
  16.  
  17. % When Population size is near to the number of samples drawn
  18. figure;
  19. x2= 0:150;
  20. m2=300;
  21. k2=100;
  22. n2=150;
  23. Px3= hygepdf(x2,m2,k2,n2);
  24. p2= k2/m2;
  25. Px4= binopdf(x2,n2,p2);
  26. plot(Px3,'r');
  27. hold
  28. plot(Px4,'b');
  29. title('WHEN POPULATION SIZE IS CLOSER TO SAMPLE');
  30. legend('Hypergeometric','Binomial');
  31. xlabel('Number of samples --->');
  32. ylabel('Probability --->');
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement