模棱两可的期望值

Ambiguous Expectation value

我在网站上看到了这个问题(我不会使用确切的措辞或提及网站),

Suppose a kid gets his pocket money on the 15th of every month, according to which day is it on that date, Lets say he gets 1 coin on Monday, 2 coins on Tuesday...7 coins on Sunday. What is the Expected number of coins he will get on the 15th of a random month?

起初我虽然每个的概率都是1/7所以答案应该是4,但是它说错误答案。

然后想了想如何选择一个随机月份,并记得日历每 400 年重复一次,所以我想这可能与此有关,所以我写了以下代码:

int Date(int mn,int yr)
{
    if( ( yr%400==0 || (yr%100!=0 && yr%4==0) ) && mn==2)
        return 29;
    if(mn==2)
        return 28;
    if(mn==4 || mn==6 || mn==9 || mn==11)
        return 30;
    return 31;

}

int main()
{
    double coins=0;
    int wk=0;

    for(int yr=1;yr<=400;yr++)
    {
        for(int mn=1;mn<=12;mn++)
        {
            for(int dt=1;dt<=Date(mn,yr);dt++)
            {
                if(dt==15)
                    coins += wk%7 +1;
                wk++;
            }
        }
    }

    cout<<setprecision(10)<<coins/12/400;
}

输出-

4.001666667

还有宾果游戏!正确答案! 但仔细想想,我意识到我选择星期一作为开始日,但它不能是任何一天吗? 所以我对程序做了这个小改动 -

int main()
{
    double total=0;

    for(int i=0;i<7;i++)
    {
        int wk=i;
        double coins=0;
        for(int yr=1;yr<=400;yr++)
        {
            for(int mn=1;mn<=12;mn++)
            {
                for(int dt=1;dt<=Date(mn,yr);dt++)
                {
                    if(dt==15)
                        coins += wk%7 +1;
                    wk++;
                }
            }
        }
        cout<<setprecision(10)<<coins/12/400<<endl;
        total += coins;
    }

    cout<<endl<<setprecision(10)<<total/7/12/400;
}

输出-

4.001666667
3.998333333
4.000833333
3.998958333
4
4.001041667
3.999166667

4

Soooo...现在真的很困惑...我们应该只接受它 4.00666 因为它是 0001 年 1 月 1 日星期一,或者问题可能有任何答案或者我在这里遗漏了一些非常重要的东西?

正确答案应该是什么?
如果不存在“正确”答案,那么您认为最合适的答案是什么?

您的扩展结果只能用 400 年期间内各月的弱天数分布不均来解释。

这与以下事实有关:工作日以 7 为基础的周期重复,而闰年以 4 为基础的周期重复(有扩展),而且月份的长度也不相等,因此尽管日历在 400 之后重复天,您选择的开始日期可能会有一些依赖性(显然 )。

不过,我们可以更轻松地做到这一点:你有 400 年,每一年有 12 个月,我。 e. 3600个月。 3600 不能被 7 整除,所以工作日 不能 平均分配给月份,所以你 必须 根据选择的开始得到一些差异日...

现在有问题的是最外层 for 循环中的这两行:

int wk=i;
for(int yr=1;yr<=400;yr++)

您将 特定 年份的开始日期设置为 [0..6] 中的任意值。然而,这 7 个值中只有一个实际匹配所选年份,其他 6 个值定义了一些幻想日历(你的出生日期是固定的,找出它是哪一天 - 然后想象你将它更改为所有其他日期一周...)。

旁注:实际上,您使用公历(计算所基于的公历)是从引入公历时向后使用的,这样做,您还必须计算第 1 年的正确开始日期。碰巧它也(几乎)是星期一,所以你幸运地得到了正确的结果......

Soooo...now am really confused...should we just take it 4.00666 'cause it was Monday on 1st Jan 0001

是的,当然我们目前的日历系统当时还没有使用。如果您选择另一个开始日期,您将针对我们实际使用的其他日历系统进行计算。

请注意,Jan 1 1、Jan 1 401、Jan 1 801、Jan 1 1201 等都是一周中的同一天(同样在我们当前的日历系统中)。您不必专门选择第 1 年,但您必须选择您选择的 400 年期间的开始。

您已经完成了所有必要的思考工作,甚至更多;但你过于笼统了。

I realized that i choose Monday to be the starting day, But couldn't it be any day?

不,如果问题是在这个宇宙中设置的,则不会。

should we just take it 4.00666 'cause it was Monday on 1st Jan 0001

“1 月 1 日”并不是一个明确指定的年份,因为那时公历和儒略历都不存在。

or the question could have any answer or am I missing something very important here?

What should be the correct answer for this?

这个问题只有一个正确答案,4.001666,因为在这个宇宙中,工作日与年份是如何排列的。 1900 年 1 月 1 日(我们可以在任何我们喜欢的地方开始一个 400 年的循环,只要它是在采用公历之后)是一个星期一,所以请更新您的 first main 来自

for(int yr=1;yr<=400;yr++)

for(int yr=1900; yr < 1900+400; yr++)

你会马上得到正确答案。


正如已经确定的那样,工作日与年份对齐的特定方式是导致此处 'potential' 答案差异的原因。为什么the 13th of the month is more likely to fall on a Friday than on any other day of the week.

背后的原因是一样的