Share Pastebin
Guest
Public paste!

supa

By: a guest | Jan 28th, 2010 | Syntax: None | Size: 0.63 KB | Hits: 101 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. trials = 100000;
  2. X_vector = random( ' Binomial ' , 10 , 0.6 , 1 , trials )
  3. for i.html">i=1:11
  4. count ( i.html">i , 1 ) = i-1 ;
  5. count ( i.html">i , 2 ) = sum( ( i-1) == X_vector ) ;
  6. end
  7. bar ( count ( : , 1 ) , count ( : , 2 ) / trials ) ;
  8.  
  9. Simulate and plot the probability mass functions for the following random variables:
  10. 1. Binomial with parameters n = 20 and p = 0.2 (you will need more bins in your histogram)
  11. 2. Geometric random variable with parameter p = 0.1 (choose reasonable number of bins). Note that they
  12. define the geometric as the number of failures after a success which is why you can get zero.
  13. 3. Poisson random variable with parameter lamda= 3