None is correct: Exercise 10 Programming Assignment: Loaded Dice

Hey,

It turns out that none of the options for exercise 10 is correct.

Given a 6-sided loaded dice. You throw it twice and record the sum. Which of the following statemets is true?

d. changing the loaded side from 1 to 6 will yield a higher mean but the same variance

First of all the question has a typo. statemets should be changed into statements.

I got the answer right but option d is actually not correct. Variance would not be the same. I guess the author of the assessment meant covariance instead of variance.
Other options are wrong obviously.

1 Like

Hi @pang.luo,

Thank you for your comments! I will forward it to our Curriculum Engineer @a-zarta, who is more capable of answering this specific question regarding the Assignment.

Thanks,
Lucas

Issue still exist.

Select “changing the loaded side from 1 to 6 will yield a higher mean but the same variance” will pass the test, but obviously this answer is wrong.

Code to validate the mean and var:

def calculate_n(n):
    print(n)
    low = 1 / 7
    high = 2 / 7
    E = 0
    for i in range(1, 7):
        if i == n:
            E += high * i
        else:
            E += low * i
    print(f"E: {E}")
    var = 0
    for i in range(1, 7):
        if i == n:
            var += high * (i - E) ** 2
        else:
            var += low * (i - E) ** 2
    print(f"var: {var}")
    cov = 0
    Exy = 0
    for i in range(1, 7):
        for j in range(1, 7):
            if i == n and j == n:
                Exy += high * high * i * j
            elif (i == n and j != n) or (i != n and j == n):
                Exy += high * low  * i * j
            else:
                Exy += low * low * i * j
    print(f"cov: {Exy - E ** 2}")


for i in range(1, 7):
    calculate_n(i)

Can help check again pls? thanks!
@lucas.coutinho

If you prefer simulate solution:

def roll_loaded(n):
    dice = [1, 2, 3, 4, 5, 6]
    dice.append(n)
    number_iterations = 10_000
    np.random.seed(42)
    throw_1 = []
    throw_2 = []
    for i in range(number_iterations):
        throw_1.append(np.random.choice(dice))
        throw_2.append(np.random.choice(dice))

    sum_throw = np.array(throw_1) + np.array(throw_2)
    print(
        n,
        "\n mean:",
        np.mean(sum_throw),
        "\n var:",
        np.var(sum_throw),
        "\n cov:",
        np.cov(throw_1, throw_2),
    )


for i in range(1, 7):
    roll_loaded(i)