title: "sample" and "rbinom" functions in R
body: <p>I guess it has been asked before, but I'm still a bit rusty about "sample" and "rbinom" functions in R, and would like to ask the following two simple questions:</p>
  
  <p>a) Let's say we have:</p>
  
  <pre><code>        rbinom(n = 5, size = 1, prob = c(0.9,0.2,0.3))
  </code></pre>
  
  <p>So "n" = 5 but "prob" is only indicated for three of them. What values R assigns for these two n's?</p>
  
  <p>b) Let's say we have:</p>
  
  <pre><code>        sample(x = 1:3, size = 1, prob = c(.5,0.2,0.9))
  </code></pre>
  
  <p>According to R-help (?sample):</p>
  
  <pre><code>     The optional prob argument can be used to give a vector of weights    
       for obtaining the elements of the vector being sampled.  
       They need not sum to one, but they should be non-negative and not all zero.
  </code></pre>
  
  <p>The question would be: why "prob" does not need sum to one?</p>
  
  <p>Any answers would be very appreciated: thank you!</p>