⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 balls.m

📁 一些常被用于教学或者参考的概率论的实例的源代码
💻 M
字号:
%balls.m/created by PJNahin for "Duelling Idiots"(12/19/98)
%This m-file calculates two quantities; (1) the average number of
%drawings (with replacement) of numbered balls before a repetition
%occurs, and (2) the largest number of drawings that still allows
%the probability there is NOT a repetition is still greater than 1/2.
%
%
n=input('How many balls are in the urn? ')
F=1/n;
E=F;
j=1;
NF=F*(n-j)/n;
while NF>0
   F=NF;
   j=j+1;
   NF=F*(n-j)/n;
   E=E+j*j*F;
end
E
j=0;
Prod=1;
while Prod > .5
   Prod=Prod*((n-j)/n);
   j=j+1;
end
T=j-1;
T

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -