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

📄 qbinom.m

📁 一个非常实用的统计工具箱
💻 M
字号:
function  k = qbinom(pr,n,p)%QBINOM  The binomial inverse cdf%%        k = qbinom(pr,n,p)%       Anders Holtsberg, 16-03-95%       Copyright (c) Anders Holtsberg% The algorithm contains a nice vectorization trick which% relies on the fact that if two elements in a vector% are exactely the same then matlab's routine SORT sorts them% into the order they had. Do not change this, Mathworks!if max([length(n) length(p)]) > 1   error('Sorry, this is not implemented');endif any(pr(:)>1) | any(pr(:)<0)   error('A probability should be 0<=p<=1, please!')endkk = (0:n)';cdf = max(0,min(1,cumsum(dbinom(kk,n,p))));cdf(n+1) = 1;[pp,J] = sort(pr(:));np = length(pp);[S,I] = sort([pp;cdf]);I = find(I<=np) - (1:np)'; J(J) = (1:np)';pr(:) = I(J);k = pr;

⌨️ 快捷键说明

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