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

📄 binomial.m

📁 一些常被用于教学或者参考的概率论的实例的源代码
💻 M
字号:
function     bc=binomial(top,bottom)
%Created by PJNahin for "Duelling Idiots"(6/3/98)
%BINOMIAL computes the binomial coefficient (top)
%                                           (bottom)
%which is equal to:  top!/((top-bottom)!(bottom)!).
%Both top and bottom must be non-negative integers
%with bottom <= top.
%
%
if top==0|top==1         %if top = 0 or 1 then
                         %top! = 1
   num=1;
else
   x=2:top;              %otherwise form 2x3x...xtop
   num=prod(x);          %to get top!
end
if bottom==0|bottom==1   %ditto for bottom!
   den1=1;
else
   x=2:bottom;
   den1=prod(x);
end
test=top-bottom;
if test==0|test==1        %ditto for (top-bottom)!
   den2=1;
else
   x=2:test;
   den2=prod(x);
end
bc=(num/den1)/den2;
   

⌨️ 快捷键说明

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