问题
I have an assignment and now got confused about exponential distribution. The instruction say "service time is exponential distributed with intensity lambda=3
." First I thought generating this is just exp(3)
, but using Matlab I am wondering if this is right interpretation of the text. Maybe I should use exprnd(3)
instead?
回答1:
If the service time distribution, S, is exponentially distributed with rate lambda = 3, then the average service time is 1/3.
You'll see the Exponential distribution often parameterized by the rate lambda, but MATLAB uses the mean. You can see MATLAB's parameterization here in the documentation.
To generate service times, one can use exprnd
directly or use the inverse transform for the Exponential distribution.
N = 4000;
lambda = 3; % Rate Note: AvgSvcTime = 1 / lambda
SvcTimes = exprnd(1/lambda,N,1); % Approach 1
U = rand(N,1); % U ~ Uniform(0,1)
SvcTimes2 = -(1/lambda)*log(1-U); % Approach 2 with Inverse Transform
Note: You can replace 1-U
with U
since they are equal in distribution.
来源:https://stackoverflow.com/questions/37529525/generate-a-exponential-distribution-with-lambda%c2%b43