1. Home
  2. Explore
  3. Computer Science
  4. CS109 Course Feedback Process

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

CS109 Course Feedback Process

  • 21Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Random Variables and PMF

What is a probability mass function (PMF) of a random variable?

21 questions

  1. 1

    What is a probability mass function (PMF) of a random variable?

    1. A

      A function that gives the cumulative probability up to a value

    2. B

      A function that maps each possible value of the random variable to its probability

    3. C

      A function that computes the expected value of the random variable

    4. D

      A function that determines the variance of the random variable

    Correct answer
    B

    A function that maps each possible value of the random variable to its probability

    Explanation

    The PMF assigns probabilities to each value that a discrete random variable can take. It is the fundamental description of the random variable's distribution.

  2. 2

    How is the expectation of a random variable XXX defined?

    1. A

      E[X]=∑xx2P(X=x)E[X] = \sqrt{\sum_x x^2 P(X=x)}E[X]=∑x​x2P(X=x)​

    2. B

      E[X]=∑x(x−μ)2P(X=x)E[X] = \sum_x (x - \mu)^2 P(X=x)E[X]=∑x​(x−μ)2P(X=x)

    3. C

      E[X]=∑xx⋅P(X=x)E[X] = \sum_x x \cdot P(X=x)E[X]=∑x​x⋅P(X=x)

    4. D

      E[X]=∑xP(X=x)E[X] = \sum_x P(X=x)E[X]=∑x​P(X=x)

    Correct answer
    C

    E[X]=∑xx⋅P(X=x)E[X] = \sum_x x \cdot P(X=x)E[X]=∑x​x⋅P(X=x)

    Explanation

    Expectation is the weighted average of possible values, weighted by their probabilities: E[X]=∑xx⋅P(X=x)E[X] = \sum_x x \cdot P(X=x)E[X]=∑x​x⋅P(X=x).

  3. 3

    What does the law of linearity of expectation state?

    1. A

      For any random variable XXX, E[aX+b]=aE[X]+bE[aX+b] = aE[X] + bE[aX+b]=aE[X]+b

    2. B

      Both A and C are correct

    3. C

      For any random variables XXX and YYY, E[X+Y]=E[X]+E[Y]E[X+Y] = E[X] + E[Y]E[X+Y]=E[X]+E[Y]

    4. D

      For any random variables XXX and YYY, E[XY]=E[X]E[Y]E[XY] = E[X]E[Y]E[XY]=E[X]E[Y]

    Correct answer
    B

    Both A and C are correct

    Explanation

    Linearity of expectation includes both additivity (E[X+Y]=E[X]+E[Y]E[X+Y]=E[X]+E[Y]E[X+Y]=E[X]+E[Y]) and scalar multiplication (E[aX+b]=aE[X]+bE[aX+b]=aE[X]+bE[aX+b]=aE[X]+b). It holds regardless of dependence.

  4. 4

    What is the Law of the Unconscious Statistician (LOTUS)?

    1. A

      For any function ggg, E[g(X)]=g(E[X])E[g(X)] = g(E[X])E[g(X)]=g(E[X])

    2. B

      For a function ggg, E[g(X)]=∑xg(x)P(X=x)E[g(X)] = \sum_x g(x) P(X=x)E[g(X)]=∑x​g(x)P(X=x)

    3. C

      For any linear function ggg, E[g(X)]=g(E[X])E[g(X)] = g(E[X])E[g(X)]=g(E[X])

    4. D

      For a function ggg, E[g(X)]=∑xx⋅P(g(X)=x)E[g(X)] = \sum_x x \cdot P(g(X)=x)E[g(X)]=∑x​x⋅P(g(X)=x)

    Correct answer
    B

    For a function ggg, E[g(X)]=∑xg(x)P(X=x)E[g(X)] = \sum_x g(x) P(X=x)E[g(X)]=∑x​g(x)P(X=x)

    Explanation

    LOTUS states that the expectation of a function of a random variable is the weighted average of the function values, using the original PMF.

  5. 5

    Given a dataset of values, how can you estimate the expectation?

    1. A

      By taking the mode of all the values

    2. B

      By taking the median of all the values

    3. C

      By taking the sum of all the values

    4. D

      By taking the average of all the values

    Correct answer
    D

    By taking the average of all the values

    Explanation

    The expectation is approximated by the sample average: 1n∑xi\frac{1}{n} \sum x_in1​∑xi​. This follows from the definition of probability as relative frequency.

  6. 6

    Which of the following scenarios describes a binomial random variable?

    1. A

      Number of defective items in a sample of size nnn drawn without replacement

    2. B

      Number of successes until the first failure in independent trials

    3. C

      Number of heads in 10 independent coin flips

    4. D

      Time until the first success in a sequence of independent trials

    Correct answer
    C

    Number of heads in 10 independent coin flips

    Explanation

    A binomial random variable counts the number of successes in a fixed number nnn of independent Bernoulli trials, each with success probability ppp. Coin flips with a fixed number are a classic example.

  7. 7

    What are the parameters of a binomial distribution?

    1. A

      nnn (number of trials) and kkk (number of successes)

    2. B

      nnn (number of trials) and ppp (probability of success)

    3. C

      μ\muμ (mean) and σ2\sigma^2σ2 (variance)

    4. D

      kkk (number of successes) and ppp (probability of success)

    Correct answer
    B

    nnn (number of trials) and ppp (probability of success)

    Explanation

    A binomial random variable is defined by nnn, the number of independent trials, and ppp, the probability of success on each trial.

  8. 8

    What is the probability mass function of a binomial random variable X∼Bin(n,p)X \sim \text{Bin}(n, p)X∼Bin(n,p)?

    1. A

      P(X=k)=n!k!(n−k)!pk(1−p)kP(X=k) = \frac{n!}{k!(n-k)!} p^k (1-p)^{k}P(X=k)=k!(n−k)!n!​pk(1−p)k

    2. B

      P(X=k)=(nk)pn−k(1−p)kP(X=k) = \binom{n}{k} p^{n-k} (1-p)^kP(X=k)=(kn​)pn−k(1−p)k

    3. C

      P(X=k)=(nk)pk(1−p)n−kP(X=k) = \binom{n}{k} p^k (1-p)^{n-k}P(X=k)=(kn​)pk(1−p)n−k

    4. D

      P(X=k)=(nk)pk(1−p)kP(X=k) = \binom{n}{k} p^k (1-p)^kP(X=k)=(kn​)pk(1−p)k

    Correct answer
    C

    P(X=k)=(nk)pk(1−p)n−kP(X=k) = \binom{n}{k} p^k (1-p)^{n-k}P(X=k)=(kn​)pk(1−p)n−k

    Explanation

    The PMF is P(X=k)=(nk)pk(1−p)n−kP(X=k) = \binom{n}{k} p^k (1-p)^{n-k}P(X=k)=(kn​)pk(1−p)n−k, where kkk successes occur in nnn trials.

  9. 9

    If X∼Bin(1000,0.01)X \sim \text{Bin}(1000, 0.01)X∼Bin(1000,0.01), what Python code computes P(X=10)P(X=10)P(X=10)?

    1. A

      stats.binom.pmf(10, 1000, 0.01)

    2. B

      stats.binom.pmf(1000, 10, 0.01)

    3. C

      stats.binom.cdf(10, 1000, 0.01)

    4. D

      stats.binom.pmf(10, 0.01, 1000)

    Correct answer
    A

    stats.binom.pmf(10, 1000, 0.01)

    Explanation

    The function stats.binom.pmf(k, n, p) returns the probability of exactly kkk successes. The order is kkk, then nnn, then ppp.

  10. 10

    How do you compute the probability that a binomial random variable XXX is less than 10, given n=1000n=1000n=1000 and p=0.01p=0.01p=0.01?

    1. A

      Use binom.pmf(10,1000,0.01)\text{binom.pmf}(10, 1000, 0.01)binom.pmf(10,1000,0.01)

    2. B

      Sum binom.pmf(k,1000,0.01)\text{binom.pmf}(k, 1000, 0.01)binom.pmf(k,1000,0.01) for k=0k=0k=0 to 999

    3. C

      Use binom.cdf(10,1000,0.01)\text{binom.cdf}(10, 1000, 0.01)binom.cdf(10,1000,0.01)

    4. D

      Sum binom.pmf(k,1000,0.01)\text{binom.pmf}(k, 1000, 0.01)binom.pmf(k,1000,0.01) for k=0k=0k=0 to 101010

    Correct answer
    B

    Sum binom.pmf(k,1000,0.01)\text{binom.pmf}(k, 1000, 0.01)binom.pmf(k,1000,0.01) for k=0k=0k=0 to 999

    Explanation

    Since the events X=kX=kX=k are mutually exclusive, P(X<10)=∑k=09P(X=k)P(X<10) = \sum_{k=0}^{9} P(X=k)P(X<10)=∑k=09​P(X=k). The CDF (option 2) gives P(X≤10)P(X \leq 10)P(X≤10), which is not strictly less than 10.

  11. 11

    What is the expectation of a binomial random variable X∼Bin(n,p)X \sim \text{Bin}(n, p)X∼Bin(n,p)?

    1. A

      np(1−p)np(1-p)np(1−p)

    2. B

      npnpnp

    3. C

      n(1−p)n(1-p)n(1−p)

    4. D

      ppp

    Correct answer
    B

    npnpnp

    Explanation

    The expectation of a binomial is E[X]=npE[X] = npE[X]=np, which can be derived by writing XXX as a sum of Bernoulli random variables and using linearity of expectation.

  12. 12

    What is a Bernoulli random variable?

    1. A

      A random variable that takes value 1 with probability ppp and 0 with probability 1−p1-p1−p

    2. B

      A random variable that takes any integer value with equal probability

    3. C

      A random variable that models the time between events

    4. D

      A random variable that counts the number of successes in nnn trials

    Correct answer
    A

    A random variable that takes value 1 with probability ppp and 0 with probability 1−p1-p1−p

    Explanation

    A Bernoulli random variable is a special case of binomial with n=1n=1n=1. It represents a single trial with success probability ppp.

  13. 13

    How is a binomial random variable related to Bernoulli random variables?

    1. A

      A binomial is the product of nnn independent Bernoulli random variables

    2. B

      A binomial and Bernoulli are unrelated

    3. C

      A binomial is the sum of nnn independent and identically distributed Bernoulli random variables

    4. D

      A Bernoulli is the sum of nnn independent binomial random variables

    Correct answer
    C

    A binomial is the sum of nnn independent and identically distributed Bernoulli random variables

    Explanation

    If Xi∼Ber(p)X_i \sim \text{Ber}(p)Xi​∼Ber(p) are i.i.d., then X=∑i=1nXi∼Bin(n,p)X = \sum_{i=1}^n X_i \sim \text{Bin}(n, p)X=∑i=1n​Xi​∼Bin(n,p).

  14. 14

    What is the expectation of a Bernoulli random variable X∼Ber(p)X \sim \text{Ber}(p)X∼Ber(p)?

    1. A

      000

    2. B

      ppp

    3. C

      p(1−p)p(1-p)p(1−p)

    4. D

      1−p1-p1−p

    Correct answer
    B

    ppp

    Explanation

    Using the definition: E[X]=1⋅p+0⋅(1−p)=pE[X] = 1 \cdot p + 0 \cdot (1-p) = pE[X]=1⋅p+0⋅(1−p)=p.

  15. 15

    Which of the following is NOT an example of a Bernoulli random variable?

    1. A

      The number of heads in 10 coin flips

    2. B

      Whether a randomly selected voter supports a candidate

    3. C

      Whether a single coin flip lands heads

    4. D

      Whether a single computer crashes

    Correct answer
    A

    The number of heads in 10 coin flips

    Explanation

    A Bernoulli random variable results from a single trial. The number of heads in 10 flips is a binomial, not Bernoulli.

  16. 16

    What does variance measure in a distribution?

    1. A

      The spread or dispersion of values around the mean

    2. B

      The probability of extreme values

    3. C

      The skewness of the distribution

    4. D

      The central value of the distribution

    Correct answer
    A

    The spread or dispersion of values around the mean

    Explanation

    Variance quantifies how much the values of a random variable differ from the expectation, on average.

  17. 17

    What is the definition of variance of a random variable XXX?

    1. A

      Var(X)=E[∣X−μ∣]\text{Var}(X) = E[|X - \mu|]Var(X)=E[∣X−μ∣]

    2. B

      Var(X)=E[(X−μ)2]\text{Var}(X) = E[(X - \mu)^2]Var(X)=E[(X−μ)2] where μ=E[X]\mu = E[X]μ=E[X]

    3. C

      Var(X)=E[X2]−(E[X])2\text{Var}(X) = E[X^2] - (E[X])^2Var(X)=E[X2]−(E[X])2

    4. D

      Var(X)=(E[X])2−E[X2]\text{Var}(X) = (E[X])^2 - E[X^2]Var(X)=(E[X])2−E[X2]

    Correct answer
    B

    Var(X)=E[(X−μ)2]\text{Var}(X) = E[(X - \mu)^2]Var(X)=E[(X−μ)2] where μ=E[X]\mu = E[X]μ=E[X]

    Explanation

    The definition is Var(X)=E[(X−μ)2]\text{Var}(X) = E[(X - \mu)^2]Var(X)=E[(X−μ)2], the expected squared deviation from the mean. Option D is an equivalent formula derived from this definition.

  18. 18

    Which of the following is an equivalent formula for variance?

    1. A

      Var(X)=E[X2]+(E[X])2\text{Var}(X) = E[X^2] + (E[X])^2Var(X)=E[X2]+(E[X])2

    2. B

      Var(X)=(E[X])2−E[X2]\text{Var}(X) = (E[X])^2 - E[X^2]Var(X)=(E[X])2−E[X2]

    3. C

      Var(X)=E[X2]−(E[X])2\text{Var}(X) = E[X^2] - (E[X])^2Var(X)=E[X2]−(E[X])2

    4. D

      Var(X)=E[(X+μ)2]\text{Var}(X) = E[(X+\mu)^2]Var(X)=E[(X+μ)2]

    Correct answer
    C

    Var(X)=E[X2]−(E[X])2\text{Var}(X) = E[X^2] - (E[X])^2Var(X)=E[X2]−(E[X])2

    Explanation

    Using LOTUS and algebra, Var(X)=E[X2]−(E[X])2\text{Var}(X) = E[X^2] - (E[X])^2Var(X)=E[X2]−(E[X])2, which is often easier to compute.

  19. 19

    How is standard deviation related to variance?

    1. A

      Standard deviation is the same as variance

    2. B

      Standard deviation is the square of variance

    3. C

      Standard deviation is the reciprocal of variance

    4. D

      Standard deviation is the square root of variance

    Correct answer
    D

    Standard deviation is the square root of variance

    Explanation

    Standard deviation σ=Var(X)\sigma = \sqrt{\text{Var}(X)}σ=Var(X)​ is in the same units as the original random variable, unlike variance.

  20. 20

    In the context of the lecture, why is variance important for evaluating peer grading accuracy?

    1. A

      Variance determines the highest grade possible

    2. B

      Variance measures the average grade given

    3. C

      Variance captures how much the grades given by a peer deviate from the true grade

    4. D

      Variance indicates the number of students who grade

    Correct answer
    C

    Variance captures how much the grades given by a peer deviate from the true grade

    Explanation

    Two graders may have the same average (expectation) but different spreads. Variance quantifies the spread, helping to assess accuracy.

  21. 21

    Using LOTUS, how would you compute E[X2]E[X^2]E[X2] for a discrete random variable XXX?

    1. A

      E[X2]=∑xx2P(X=x)E[X^2] = \sum_x x^2 P(X=x)E[X2]=∑x​x2P(X=x)

    2. B

      E[X2]=(∑xxP(X=x))2E[X^2] = \left(\sum_x x P(X=x)\right)^2E[X2]=(∑x​xP(X=x))2

    3. C

      E[X2]=∑xxP(X=x)2E[X^2] = \sum_x x P(X=x)^2E[X2]=∑x​xP(X=x)2

    4. D

      E[X2]=∑x(xP(X=x))2E[X^2] = \sum_x (x P(X=x))^2E[X2]=∑x​(xP(X=x))2

    Correct answer
    A

    E[X2]=∑xx2P(X=x)E[X^2] = \sum_x x^2 P(X=x)E[X2]=∑x​x2P(X=x)

    Explanation

    LOTUS: E[g(X)]=∑xg(x)P(X=x)E[g(X)] = \sum_x g(x) P(X=x)E[g(X)]=∑x​g(x)P(X=x). For g(x)=x2g(x)=x^2g(x)=x2, we get E[X2]=∑xx2P(X=x)E[X^2] = \sum_x x^2 P(X=x)E[X2]=∑x​x2P(X=x).

Question 1 of 21
Question 1 of 21

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent