hypg_rnd.m

来自「计量工具箱」· M 代码 · 共 29 行

M
29
字号
function  x = hypg_rnd(num,n,K,N)
% PURPOSE: hypergeometric random draws
% prob(X=x) = (N)^-1 (K)(N-K)
%             (n)    (x)(n-x)
%---------------------------------------------------
% USAGE:     x = hypg_rnd(nobs,n,K,N)
% where:  nobs = number of draws
%        n,K,N = parameters of the distribution 
% NOTE: mean     = (n/N)*k
%       variance = [(n*K)/(N*N)*(N-1)]*(N-K)*(N-n)
%---------------------------------------------------
% RETURNS:
%        a vector of random draws from the distribution      
% --------------------------------------------------
% SEE ALSO: hypg_cdf, hypg_rnd, hypg_inv
%---------------------------------------------------

%       Anders Holtsberg, 18-11-93
%       Copyright (c) Anders Holtsberg
% documentation changed to match the econometrics toolbox
% by LeSage

if length(num)==1
   num = [num 1];
end
x = hypg_inv(rand(num),n,K,N);


⌨️ 快捷键说明

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