title: How do I calculate expected value and variance, then simulate 500 samples from this distribution in R
body: <p>Assume we have a discrete random variable with probability function given by </p>
  
  <pre><code>x = c(0, 3, 5, 10)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>px = c(0.2, 0.1, 0.1, 0.6)
  </code></pre>
  
  <p>How do I calculate expected value and variance, then simulate 500 samples from this distribution in R?</p>