关于87.53%的数学分析

7 评论24次阅读2009.12.13 1:09; 作者:Felicia 

最近有个统计数据非常火,那就是:

国家统计局称,在他们随机调查的100位网友中,有87.53%的网友支持封杀BTchina.

虽然我数学差,但是还是知道这是不可能的。

分析:

假设调查结果只有两种可能:支持或反对,弃权算作无效问卷。

如果100份问卷都是有效问卷,那么最后结果(写成百分数形式),百分号前面肯定是整数。

因为87.53是小数,所以100份问卷不可能都是有效的,必定有无效问卷。

那么我写个程序枚举100份问卷中有多少份有效问卷,再枚举有效问卷中有多少份回答的是支持,那么就枚举了所有的计算结果。

#include <stdio.h>
#include <string.h>
 
int main() {
    
char t[10];
    
int sample_size, cnt = 0;
    
printf("Please enter a percentage with two decimal places (like 87.53), I will help you deside how it is calculated: ");
    
scanf("%s", t);
    
    
printf("Please enter the sample size: ");
    
scanf("%d", &sample_size);
    
    
for (int i = 0; i <= sample_size; ++i) {
        
for (int j = 0; j <= i; ++j) {
            
char s[10];
            
sprintf(s, "%.2lf", j * 100.0 / i);
            
if (strcmp(s, t) == 0) {
                
printf("%d/%d = %lf%%\n", j, i, j * 100.0 / i);
                ++
cnt;
            
}
        
}
    
}
    
printf("Total possibilities = %d\n", cnt);
    
return 0;
}

输入87.53, 样本大小100。
程序遍历了所有的计算可能,并没有找到能算出87.53的可能。
我试着扩大样本大小,发现至少要有361份问卷,才能统计出87.53%这个数字,因为 316/361 = 87.534626% 是在%0.005精度内逼近87.53%的分数中分母最小的一个。

附录:1000份问卷,统计出87.53%的所有可能。分子是回答“支持”的问卷数,分母是有效问卷数。

316/361 = 87.534626%
323/369 = 87.533875%
330/377 = 87.533156%
337/385 = 87.532468%
344/393 = 87.531807%
351/401 = 87.531172%
358/409 = 87.530562%
365/417 = 87.529976%
372/425 = 87.529412%
379/433 = 87.528868%
386/441 = 87.528345%
393/449 = 87.527840%
400/457 = 87.527352%
407/465 = 87.526882%
414/473 = 87.526427%
421/481 = 87.525988%
428/489 = 87.525562%
435/497 = 87.525151%
632/722 = 87.534626%
639/730 = 87.534247%
646/738 = 87.533875%
653/746 = 87.533512%
660/754 = 87.533156%
667/762 = 87.532808%
674/770 = 87.532468%
681/778 = 87.532134%
688/786 = 87.531807%
695/794 = 87.531486%
702/802 = 87.531172%
709/810 = 87.530864%
716/818 = 87.530562%
723/826 = 87.530266%
730/834 = 87.529976%
737/842 = 87.529691%
744/850 = 87.529412%
751/858 = 87.529138%
758/866 = 87.528868%
765/874 = 87.528604%
772/882 = 87.528345%
779/890 = 87.528090%
786/898 = 87.527840%
793/906 = 87.527594%
800/914 = 87.527352%
807/922 = 87.527115%
814/930 = 87.526882%
821/938 = 87.526652%
828/946 = 87.526427%
835/954 = 87.526205%
842/962 = 87.525988%
849/970 = 87.525773%
856/978 = 87.525562%
863/986 = 87.525355%
870/994 = 87.525151%

相关文章

  • 评论 (7)
  • 引用通告 (0)
发表评论 引用通告

  • CD | 回复 1F

    十二月 13th, 2009 at 23:54

    orz
    大牛你介意我转么?

    • Felicia | 回复 2F

      十二月 16th, 2009 at 21:15

      欢迎转载:)留个链接就好了

  • jjymhkx0820 | 回复 3F

    十二月 17th, 2009 at 17:17

    这个好牛哈,哈哈。

  • felix021 | 回复 4F

    十二月 17th, 2009 at 19:25

    int t[10]; <– 溢出攻击你的代码,哇哈哈

    scanf("%10s", t); <– 这么写~。~

    • Felicia | 回复 5F

      十二月 21st, 2009 at 17:28

      晕……果然有漏洞。多谢提醒

  • ff8885b | 回复 6F

    二月 10th, 2010 at 18:05

    为什么要用两层循环啊?明明可以O(2n)的情况下解决啊,干嘛用O(n*n)啊
    #include
    #include

    int main() {
    char t[10];
    int sample_size, cnt = 0;
    printf(“Please enter a percentage with two decimal places (like 87.53), I will help you deside how it is calculated: “);
    scanf(“%s”, t);

    printf(“Please enter the sample size: “);
    scanf(“%d”, &sample_size);

    for (int i = 0; i <= sample_size; ++i) {
    char s[10];
    int j;
    j=i*atof(t);
    sprintf(s, "%.2lf", j * 100.0 / i);
    if (strcmp(s, t) == 0) {
    printf("%d/%d = %lf%%\n", j, i, j * 100.0 / i);
    ++cnt;
    }
    j=i*atof(t)+1;
    sprintf(s, "%.2lf", j * 100.0 / i);
    if (strcmp(s, t) == 0) {
    printf("%d/%d = %lf%%\n", j, i, j * 100.0 / i);
    ++cnt;
    }
    }
    printf("Total possibilities = %d\n", cnt);
    return 0;
    }

    • Felicia | 回复 7F

      二月 19th, 2010 at 15:59

      随手写了个,没考虑时间效率,sorry

暂无引用通告