Re: [血尿] 德天使
看板SD-GundamOL (SD鋼彈 Online)作者leafwind (有葉玉米)時間15年前 (2010/08/01 21:45)推噓9(9推 0噓 17→)留言26則, 12人參與討論串2/2 (看更多)
(補充:此篇原因為上一篇推文有人詢問
「如果每台機體機率均為1/6,那要多少抽才收集完四台天使?」
因此與現實狀況極可能有出入,因為A神龍與A死明顯機率較高)
我的機率真的不好..
結果還是寫程式讓他統計比較快= =
=====output=====
test if it is a fair dice in 600,000 tosses:
100173 99920 99318 100387 100345 99857
test start!
stop if number 1,2,3,4 have show up:
4 3 1 1 4 2 you have tossed 15 times.
stop if number 1,2,3,4 have show up:
4 4 1 3 1 3 you have tossed 16 times.
stop if number 1,2,3,4 have show up:
1 1 1 2 0 1 you have tossed 6 times.
stop if number 1,2,3,4 have show up:
1 1 3 3 3 4 you have tossed 15 times.
stop if number 1,2,3,4 have show up:
1 3 4 1 5 2 you have tossed 16 times.
stop if number 1,2,3,4 have show up:
1 1 1 3 3 6 you have tossed 15 times.
stop if number 1,2,3,4 have show up:
1 3 1 3 3 2 you have tossed 13 times.
stop if number 1,2,3,4 have show up:
2 1 3 2 2 1 you have tossed 11 times.
stop if number 1,2,3,4 have show up:
1 2 1 3 3 0 you have tossed 10 times.
stop if number 1,2,3,4 have show up:
1 5 4 1 1 3 you have tossed 15 times.
Acerage toss times need: 13
這是10次平均的結果
我也有改成測十萬次,結果平均是12次左右可以集滿四天使
因為版面有限就不貼上來了
有興趣又不怕傷眼的可以幫我找找哪裡寫錯..隨便亂搞的可能有寫錯:P
另外徵求機率魔人解答..為什麼期望值是12次..我不清楚XDDD
==========
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define TEST_TIMES 100000
int main(void)
{
int i, j;
int count[6] = {0};
srand(time(NULL));
for(i = 0; i < 600000; i++)
{
count[rand()%6]++;
}
printf("test if it is a fair dice in 600,000 tosses:\n");
for(i = 0; i < 6; i++)
{
printf("%d ", count[i]);
count[i] = 0;
}
printf("\n\ntest start!\n\n");
int toss_count = 0;
int record[TEST_TIMES];
for(i = 0; i < TEST_TIMES; i++)
{
while( (!count[0]) || (!count[1]) || (!count[2]) || (!count[3]) )
{
count[rand()%6]++;
toss_count++;
}
printf("stop if number 1,2,3,4 have show up:\n");
for(j = 0; j < 6; j++)
{
printf("%d ", count[j]);
}
printf("you have tossed %d times.\n", toss_count);
record[i] = toss_count;
// reset data
for(j = 0; j < 6; j++)
{
count[j] = 0;
}
toss_count = 0;
}
// summary phase
int sum = 0;
for(i = 0; i < TEST_TIMES; i++)
{
sum += record[i];
}
int avg_toss_times = sum / TEST_TIMES;
printf("Acerage toss times need: %d\n", avg_toss_times);
return 0;
}
--
問題是扭蛋不可能公平都1/6機率阿..
那這篇不就跟SD無關了 囧>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.166.170.160
→
08/01 21:48, , 1F
08/01 21:48, 1F
推
08/01 21:58, , 2F
08/01 21:58, 2F
推
08/01 21:58, , 3F
08/01 21:58, 3F
→
08/01 21:59, , 4F
08/01 21:59, 4F
→
08/01 21:59, , 5F
08/01 21:59, 5F
→
08/01 21:59, , 6F
08/01 21:59, 6F
→
08/01 22:01, , 7F
08/01 22:01, 7F
→
08/01 22:02, , 8F
08/01 22:02, 8F
→
08/01 22:03, , 9F
08/01 22:03, 9F
推
08/01 22:12, , 10F
08/01 22:12, 10F
→
08/01 22:13, , 11F
08/01 22:13, 11F
→
08/01 22:15, , 12F
08/01 22:15, 12F
推
08/01 22:15, , 13F
08/01 22:15, 13F
→
08/01 22:15, , 14F
08/01 22:15, 14F
→
08/01 22:16, , 15F
08/01 22:16, 15F
→
08/01 22:16, , 16F
08/01 22:16, 16F
用期望值來講的確不完全正確
應該說「期望幾抽能抽到四台天使」
→
08/01 22:20, , 17F
08/01 22:20, 17F
推
08/01 22:20, , 18F
08/01 22:20, 18F
推
08/01 22:26, , 19F
08/01 22:26, 19F
※ 編輯: leafwind 來自: 118.166.170.160 (08/01 22:29)
→
08/01 22:31, , 20F
08/01 22:31, 20F
→
08/01 23:13, , 21F
08/01 23:13, 21F
推
08/01 23:45, , 22F
08/01 23:45, 22F
→
08/01 23:46, , 23F
08/01 23:46, 23F
→
08/01 23:47, , 24F
08/01 23:47, 24F
推
08/02 00:04, , 25F
08/02 00:04, 25F
推
08/02 00:11, , 26F
08/02 00:11, 26F
※ 編輯: leafwind 來自: 118.166.170.160 (08/02 00:47)
討論串 (同標題文章)
SD-GundamOL 近期熱門文章
48
51
15
20
PTT遊戲區 即時熱門文章
11
14
119
199