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

📄 exponent.m

📁 通信工具箱matlab例程1。包含多个matlab实用例程程序。
💻 M
字号:
function [out, seed] = exponent(nsize,mu,seed)

% EXPONENT .... Generates random variates from the Exponential(MU) distribution.
%
%	EXPONENT(N,M) Generates N random variates from the Exponential(MU)
%		distribution with scale parameter MU, such that the CDF is:
%				
%			F(x) =  1 - exp(-x/MU),  x >= 0;
%
%	EXPONENT(N) Generates N random variates from the Exponential(1)
%		distribution.
%	EXPONENT(N,MU,SEED) is the same but starts generating random
%		variates using the value of SEED.
%	[Y, SEED] = EXPONENT(...) will return the current value of SEED for
%		subsequent calls to the same function.

%	AUTHORS : M. Zeytinoglu & N. W. Ma
%             Department of Electrical & Computer Engineering
%             Ryerson Polytechnic University
%             Toronto, Ontario, CANADA
%
%	DATE    : August 1991.
%	VERSION : 1.0

%===========================================================================
% Modifications history:
% ----------------------
%	o	Tested (and modified) under MATLAB 4.0/4.1 08.16.1993 MZ
%===========================================================================

%-------------------------------------------------------------------------
%	Check input parameters
%-------------------------------------------------------------------------

if (nargin == 1)
    mu = 1;
elseif (nargin == 2)
    if (mu <= 0), error('parameter "mu" has to be positive.'), end
elseif (nargin == 3)
    rand('seed',seed)
end

%-------------------------------------------------------------------------
%	First generate NSIZE Y = Uniform(0,1) variates.
%	If (  Y )  -->  X = -log(1-Y)
%	   Y  = 1  -->  X = +Inf	
%-------------------------------------------------------------------------

y       =  rand(1,nsize);		
y(y==1) =  Inf*ones(size(y(y==1)));
      x = -log(1-y);

%-------------------------------------------------------------------------
%	Scale output by MU
%-------------------------------------------------------------------------

out = mu*x;
if (nargout == 2), seed = rand('seed'); end

⌨️ 快捷键说明

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