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

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

What is a random variable and how is it different from a regular variable?

22 questions

  1. 1

    What is a random variable and how is it different from a regular variable?

    Model answer

    A random variable is a numerical outcome of a random process; it takes on different values with certain probabilities, unlike a deterministic variable.

    Explanation

    Random variables are functions from sample space to real numbers, and their behavior is described by a probability distribution.

  2. 2

    What is a probability mass function (PMF)?

    Model answer

    A PMF assigns to each possible value of a discrete random variable the probability that the variable equals that value.

    Explanation

    The PMF is a complete description of a discrete random variable; it can be given as an equation, graph, or table.

  3. 3

    How do you compute the probability of an event like X≤3X \leq 3X≤3 from the PMF?

    Model answer

    Sum the PMF values for all x≤3x \leq 3x≤3: P(X≤3)=∑x≤3P(X=x)P(X \leq 3) = \sum_{x \leq 3} P(X=x)P(X≤3)=∑x≤3​P(X=x).

    Explanation

    Since events like {X=x}\{X=x\}{X=x} are mutually exclusive, the probability of a union is the sum of individual probabilities.

  4. 4

    What is the definition of expectation of a discrete random variable?

    Model answer

    The expectation is E[X]=∑xx⋅P(X=x)E[X] = \sum_{x} x \cdot P(X=x)E[X]=∑x​x⋅P(X=x), the weighted average of possible values.

    Explanation

    It represents the long-run average value of the random variable over many repetitions.

  5. 5

    How can you estimate the expectation from a dataset of observed values?

    Model answer

    Take the arithmetic mean of the data: 1n∑i=1nxi\frac{1}{n}\sum_{i=1}^n x_in1​∑i=1n​xi​.

    Explanation

    This works because the empirical distribution assigns probability 1/n1/n1/n to each observation, matching the definition of expectation.

  6. 6

    State the linearity of expectation property.

    Model answer

    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], regardless of dependence.

    Explanation

    Linearity holds for any finite sum and even for constants: E[aX+b]=aE[X]+bE[aX+b] = aE[X]+bE[aX+b]=aE[X]+b.

  7. 7

    What is the binomial random variable and what story does it model?

    Model answer

    The binomial random variable X∼Bin(n,p)X \sim \text{Bin}(n,p)X∼Bin(n,p) counts the number of successes in nnn independent trials, each with success probability ppp.

    Explanation

    Common examples include number of heads in coin flips, number of ad clicks, or number of crashes in independent runs.

  8. 8

    Write the probability mass function of a binomial random variable.

    Model answer

    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 for k=0,1,…,nk = 0,1,\ldots,nk=0,1,…,n.

    Explanation

    The binomial coefficient (nk)\binom{n}{k}(kn​) counts the number of ways to choose kkk successes, and pk(1−p)n−kp^k(1-p)^{n-k}pk(1−p)n−k is the probability of any specific sequence with kkk successes.

  9. 9

    How do you compute probabilities for a binomial distribution using Python?

    Model answer

    Use scipy.stats.binom.pmf(k, n, p) for exact probabilities, or binom.cdf for cumulative probabilities.

    Explanation

    For example, stats.binom.pmf(5, 1000, 0.01) gives P(X=5)P(X=5)P(X=5) for 1000 ads with click probability 0.01.

  10. 10

    What is the expectation of a binomial random variable?

    Model answer

    E[X]=n pE[X] = n\,pE[X]=np.

    Explanation

    This can be derived by writing XXX as a sum of nnn i.i.d. Bernoulli(ppp) variables and using linearity of expectation.

  11. 11

    Why can you add binomial probabilities for different kkk values (e.g., P(X=4 or X=5)P(X=4 \text{ or } X=5)P(X=4 or X=5))?

    Model answer

    Because events {X=k}\{X=k\}{X=k} are mutually exclusive (a random variable cannot equal two different numbers simultaneously), so P(X=4∪X=5)=P(X=4)+P(X=5)P(X=4 \cup X=5) = P(X=4) + P(X=5)P(X=4∪X=5)=P(X=4)+P(X=5).

    Explanation

    Mutual exclusivity holds for all distinct values of a discrete random variable.

  12. 12

    In a best-of-seven basketball series, why can we treat it as n=7n=7n=7 binomial trials even if the series stops early?

    Model answer

    The probability of winning the series is the same whether we imagine playing all 7 games or stopping at 4 wins, because the imaginary extra games do not change the event of winning at least 4 of the first 7.

    Explanation

    By considering all 7 games as independent Bernoulli trials, we correctly compute the probability of winning 4 or more; the early stop does not affect the probability distribution of the number of wins in the first 7 games.

  13. 13

    What is a Bernoulli random variable?

    Model answer

    A Bernoulli random variable Y∼Ber(p)Y \sim \text{Ber}(p)Y∼Ber(p) takes value 1 with probability ppp and 0 with probability 1−p1-p1−p; it models a single trial.

    Explanation

    It is a special case of the binomial with n=1n=1n=1.

  14. 14

    What is the expectation of a Bernoulli random variable?

    Model answer

    E[Y]=pE[Y] = pE[Y]=p.

    Explanation

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

  15. 15

    How can a binomial random variable be expressed in terms of Bernoulli random variables?

    Model answer

    If X∼Bin(n,p)X \sim \text{Bin}(n,p)X∼Bin(n,p), then X=∑i=1nYiX = \sum_{i=1}^n Y_iX=∑i=1n​Yi​ where each Yi∼Ber(p)Y_i \sim \text{Ber}(p)Yi​∼Ber(p) independently.

    Explanation

    This representation is useful for deriving properties like expectation and variance.

  16. 16

    What is variance and what does it measure?

    Model answer

    Variance measures the spread of a random variable around its mean; it is the average squared distance from the mean: 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

    A larger variance indicates more dispersion.

  17. 17

    What is the relationship between variance and standard deviation?

    Model answer

    Standard deviation is the square root of variance: SD(X)=Var(X)\text{SD}(X) = \sqrt{\text{Var}(X)}SD(X)=Var(X)​.

    Explanation

    Standard deviation has the same units as XXX, making it more interpretable.

  18. 18

    State the computational formula for variance.

    Model answer

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

    Explanation

    This formula follows from expanding E[(X−μ)2]=E[X2]−2μE[X]+μ2=E[X2]−μ2E[(X-\mu)^2] = E[X^2] - 2\mu E[X] + \mu^2 = E[X^2] - \mu^2E[(X−μ)2]=E[X2]−2μE[X]+μ2=E[X2]−μ2.

  19. 19

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

    Model answer

    For any 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 allows us to compute expectations of functions without finding the distribution of g(X)g(X)g(X) directly.

  20. 20

    How can you compute E[X2]E[X^2]E[X2] using LOTUS?

    Model answer

    Square each possible value and weight by its probability: E[X2]=∑xx2 P(X=x)E[X^2] = \sum_{x} x^2 \, P(X=x)E[X2]=∑x​x2P(X=x).

    Explanation

    This is a direct application of LOTUS with g(x)=x2g(x)=x^2g(x)=x2.

  21. 21

    In the peer grading example, why is variance important?

    Model answer

    Two graders can have the same expected grade but different spread; variance quantifies how much the grades deviate from the true grade, helping choose a more consistent grader.

    Explanation

    A smaller variance implies more consistent grading, even if the expectation matches the true grade.

  22. 22

    What are moments of a distribution?

    Model answer

    Moments are summary statistics; the first moment is expectation, the second central moment is variance. Higher moments (skewness, kurtosis) describe shape.

    Explanation

    Variance is the second central moment, measuring spread around the mean.

1 of 22
Question 1 of 22

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent