How can I compute p0 for given values of K,c,lambda,mu ? Thanks in advance!
2 views (last 30 days)
Show older comments
lambda=3.1;
mu=0.9;
c=4;
B=5;
K=c+B;
syms n
p1=symsum(1/factorial(n)*((lambda/mu))^n,n,0,c);
p2=((lambda/mu).^c)./factorial(c)+symsum((lambda./c*mu)^(n-c),n , (c+1), K);
p0=(p1+p2)^(-1);
2 Comments
Star Strider
on 7 Jul 2014
Write your code to do it. Document it carefully. If you have problems, post your code and any error messages it generates in full. We will do what we can to help.
Answers (1)
Star Strider
on 8 Jul 2014
It’s probably best with the limits as small as they are to simply ‘brute force’ it with a couple loops:
lambda=3.1;
mu=0.9;
c=4;
B=5;
K=c+B;
% Sum #1:
p1 = 0;
for n = 0:c
p1 = p1 + (lambda/mu)^n / factorial(n);
end
% Sum #2:
p2 = 0;
for n = c+1:K
p2 = p2 + (lambda/(c*mu))^(n-c);
end
p2 = p2 * (lambda/mu)^c / factorial(c);
p0 = 1/(p1 + p2)
produces:
p0 = 2.369758210527478E-02
Does that look like the correct range for the result?
You can easily make a function file out of it (with lambda, mu, c, B as arguments) if you need to calculate it frequently.
3 Comments
Star Strider
on 10 Jul 2014
My pleasure!
(The sincerest expression of appreciation here on MATLAB Answers is to Accept the Answer that most closely solves your problem.)
Joseph Cheng
on 10 Jul 2014
Edited: Joseph Cheng
on 10 Jul 2014
Another way to do it instead of for loops is:
lambda=3.1;
mu=0.9;
c=4;
B=5;
K=c+B;
% syms n
n1= 0:c;
n2=c+1:K;
p1=1./factorial(n1).*((lambda/mu)).^n1;
p2=((lambda/mu)^c)/factorial(c)*(lambda./(c*mu)).^(n2-c);
p0=(sum(p1)+sum(p2))^(-1)
where by you calculate for each value of 'n' and then add them up.
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!