function x = exp_rnd(muX,r,c)
% x = exp_rnd(muX, r, c)
%
% generate a matrix of a random variable distribued according to the 
% exponential distribution with parameter muX 
%
%  INPUT         DESCRIPTION
%   muX          mean of the exponential distribution         1 x 1   or  r x c
%   r            number of rows in x                                      1 x 1
%                sample of standard normal variables, possibly correlated r x c
%   c            number of cols in x                                      1 x 1
%
%  OUTPUT
%   x            sample of the exponential distribution                   r x c
%
%  EXAMPLE 
%    To plot the PDF of a single exponential random variable, ... 
%    n=10000; x=exp_rnd(1,1,n); hist(x,n/100,1); avg_x = sum(x)/n

%    Reference:   http://en.wikipedia.org/wiki/Exponential_distribution

 if any(muX<=0) || any(muX==Inf)
    error(' exp_rnd: LAMBDA must be greater than zero')
 end

 if nargin == 2
   u = norm_cdf(r);
   [r,c] = size(u);
 end
 if nargin == 3
   u = rand(r,c);
 end

 if (prod(size(muX)) == 1), muX = muX * ones(r,c); end

 x = -muX .* log( u );

% --------------------------------------------------------------  exp_rnd
% HP Gavin 2016-04-26, 2021-04-21
