Game 4: Models: Sampling from a distribution/population (Discrete r.v.)

Random Variable

  • 整體狀況/母體 (population)
  • 通常以pmf (probability mass  function,離散型隨機變數); pdf (probability density function,連續型隨機變數) 來刻畫一個可以無限取樣的母體
  • pmf/pdf 可理解為一個經標準化(面積為1)樣本無限大的長條圖(histogram)

Demo

Exercises/Play

  1. Find out the binomial random number related R commands.
  2. Prepare a 2×2 window for the following graphs of X, a Binomial(n,p) random variable n \in \mathcal{N}, p \in (0,1). For a given (n, p),
    • Plot pmf. Recall E(X)=np, Var(X)=npq
    • Plot a histogram of 10 sample from X. Compute the sample mean (\bar{x}) and sample variance s^2 = \frac{1}{10-1}\sum_{i=1}^{10}(x_i - \bar{x})^2
    • Plot a histogram of 100 sample. Compute the sample mean and sample variance.
    • Plot a histogram of 1000 sample. Compute the sample mean and sample variance.
  3. Keep the plotted window, open another window and redo the steps in 2. Compare the results. What do you observe? Does this make sense to you?

Hint codes:  g4hint.r

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s