double prob=pow(lambda,t)*exp(-lambda)/t;
cout << " The probability of " << t << " customer arriving in any one minute is " << prob << endl;
output<<" The probability of " << t << " customer arriving in one any minute is " << prob << endl;
}
}
return 0;
}
output looks like this:
Lambda = 2 i need to change this one for :"The probability of # plane attempting to land in one any minute is #."
The probability of 1 customer arriving in one any minute is 0.270671
The probability of 2 customer arriving in one any minute is 0.270671
The probability of 3 customer arriving in one any minute is 0.360894
The probability of 4 customer arriving in one any minute is 0.541341
The probability of 5 customer arriving in one any minute is 0.866146
The probability of 6 customer arriving in one any minute is 1.44358
The probability of 7 customer arriving in one any minute is 2.4747
The probability of 8 customer arriving in one any minute is 4.33073
The probability of 9 customer arriving in one any minute is 7.69907
The probability of 10 customer arriving in one any minute is 13.8583
Lambda = 3
The probability of 1 customer arriving in one any minute is 0.149361
The probability of 2 customer arriving in one any minute is 0.224042
The probability of 3 customer arriving in one any minute is 0.448084
The probability of 4 customer arriving in one any minute is 1.00819
The probability of 5 customer arriving in one any minute is 2.41965
The probability of 6 customer arriving in one any minute is 6.04913
The probability of 7 customer arriving in one any minute is 15.5549
The probability of 8 customer arriving in one any minute is 40.8316
The probability of 9 customer arriving in one any minute is 108.884
The probability of 10 customer arriving in one any minute is 293.988
for (int lambda = 2; lambda <= 3; ++lambda) {
cout << "Lambda = " << lambda << endl;
output<<" Lambda = "<< lambda<<endl;
p=pow(lambda,x)*exp(-lambda)/x;
for (int t = 1; t <= 10; t++)
{
double prob=pow(lambda,t)*exp(-lambda)/t;
if ( lambda == 2 )
{
cout << " The probability of " << t << " plane attempting to land in any one minute is " << prob << endl;
output << " The probability of " << t << " plane attempting to land in any one minute is " << prob << endl;
}
else
{
cout << " The probability of " << t << " customer arriving in any one minute is " << prob << endl;
output<<" The probability of " << t << " customer arriving in one any minute is " << prob << endl;
}
}
}
Write each loop seperately (have two for loops, rather than one nested inside the other - don't control lambda with a for).
If the numbers you're getting are wrong, then your math is wrong somewhere.
Edit to add: as I said, the link won't work for me, and if you want help you should probably show a little more willingness to learn/try/explain what you need.
Well, as I said, if the numbers you're getting are wrong, it's a problem with the math you're using. Since I can't see the question, and you're obviously unwilling to post it here, then I can't help you with that.
To have two for loops, just have two for loops in your main function. So something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int main()
{
int lambda;
lambda = 2;
for ( int i = 1; i <= 10; i++ )
{
// do the lambda=2 output
}
lambda = 3;
for ( int i = 1; i <= 10; i++ )
{
// do the lambda=3 output
}
return 0;
}
Obviously, there's better ways to do this, involving creating a function and such, but I think that'd be out of the scope of your question.
(probability) a. the arrival rate of customers in a new york bank can be estimated by using the Poisson probability function : p(x)(lambda^x*e^-lambda)/x!
x # of customer arrivals per minute
lambda average # arrivals per minute
e= exp
now lambda is 3.
p(x=1)=(3^1*exp^-3)/1!=0.149561
and the probability of two customers arriving in any one minute is the following
p(x=2)=(3^2*exp-3)/2!=0.224454
using the Poisson probability function, write c++ program that calculates and displays the probability of 1 to 10 customer arrivals in any one minute when the average arrival is 3 customers per minute.
b. the formula given in exercise a is also applicable for estimating the arrival rate of planes at a busy airport ( this situation an arriving customer is an incoming plane) using the same formula modify the program toi determine the probability of 0 to 10 planes attempting to land at an airport in any one minute period . assume that the average arrival rate for peak arrival times in two planes per minute.
that s the question and i need to put a and b together
Write a proper factorial function that returns the correct value (if you google "c++ factorial" you'll find nothing but people asking how to make a factorial function in C++, with people giving them answers).
Make your math make sense. I'd suggest making a function that takes lambda and x as an argument and returns the probability.