※ 引述《sqe123456z (\れをる大好き/)》之銘言:
: 欸不是,我覺得我數學不爛啊
: 雖然我大學讀日文系以後再也沒用到數學了,但是我當年學測也考了14級分欸
: 我剛剛看理科生看到這兩張
: 幹我想了好久都不知道這到底怎麼算出來的
: https://i.imgur.com/pdD98Fk.jpg
: https://i.imgur.com/hXudCD0.jpg
: 有沒有人能告訴我計算過程啊?
: 我的理解是手游抽卡,因為沒有限定數量
: 所以不管抽一百次還是一千次,抽中的機率應該都是1%啊
: 靠北我高中數學真的都還給老師了嗎?
: 這到底怎麼算的==
https://imgur.com/fs1T6T9
獻醜
原本想說要用log去算,發現超不準,只好直接算了
怕超過2*32次,就用10次和0.1的機率去算了
至少一次的機率==一次+兩次+...+N(抽的總次數)次
以下程式碼,才正式學C不到10天,請鞭小力點
#include<stdio.h>
#include<math.h>
int cntnis(int a,int b){
int top=1,bottom=1;
for(int i=1;i<=b;i++){
top*=(a-i+1);
bottom*=i;
}
int compute=top/bottom;
return compute;
}
double multi(double have,int havet,int nohavet){
double result=pow(have,havet)*pow((1.0-have),nohavet);
return result;
}
int main(){
int times,cntn,i;
double haveis,mulh,probability,expectation=0;
times=10;
haveis=0.1;
for(i=1;i<=times;i++){
cntn=cntnis(times,i);
mulh=multi(haveis,i,times-i);
probability=cntn*mulh;
printf("抽 %d 次中,抽中 %d 張的機率= %lf\n",times,i,probability);
expectation+=probability*i;
}
printf("抽 %d 次,機率 %.3lf 期望值為: %lf",times,haveis,expectation);
return 0;
}