How can I compute p0 for given values of K,c,lambda,mu ? Thanks in advance!

2 views (last 30 days)
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
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.
Tasos Charitonidis
Tasos Charitonidis on 7 Jul 2014
Initially, I tried to evaluate the series of p1 which is the first term of the main expression. Then, I create p2 as the second term of the main expression. Hence, in p1 the series are computed recursively for n=0:c. Similarly for p2. I broke up the expression since the Sums under consideration have different limits. However, matlab outcome is an extremely large number which is wrong. My apologies for presenting a naive question without any code. Meanwhile I am trying to correct my mistake. Thank you

Sign in to comment.

Answers (1)

Star Strider
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
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
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.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!