The arrival rate of customers at some business (e.g. bank, post office, shop etc) can be estimated using the Poisson probability function:
Poisson(X) = (A^X x e^-A)/X!
where X is a number of customer arrivals per minute, A is the average number of arrivals per minute, X! is factorial(X), and e is Euler's number (2.7182818). For example if A = 3 them the probability of one customer entering the premises is:
Poisson(X=1) = (3^1 x 2.7182818^-3)/1
= 0.149361
Develop an Ada program which takes as input a user supplied average arrival rate (A), and calculates and displays the Poisson probability associated with a range of values for X (numbers of customers arriving) according to the following:
EXAMPLE 1: Given A=9 (thus A-5 > 0) then the output would be on the following lines:
Number of | Poisson
Customers | Probability
(X) |
----------+------------
4 | 0.033737
5 | 0.060727
6 | 0.091091
7 | 0.117117
8 | 0.131756
9 | 0.131756
10 | 0.118581
11 | 0.097021
12 | 0.072765
13 | 0.050376
14 | 0.032384
EXAMPLE 1: Given A=2 (thus A-5 <= 0)) the output will be of the form:
Number of | Poisson
Customers | Probability
(X) |
----------+------------
1 | 0.270671
2 | 0.270671
3 | 0.180447
4 | 0.090224
5 | 0.036089
6 | 0.012030
7 | 0.003437
Assume that A is a positive integer between 1 and 10, and that output should be given accurate to 6 decimal places.
Note 1: The factorial program given in lectures is designed to operate using integers up to a maximum of !12. To solve the above problem you will need a FLOAT version.
Note 2: Euler's constant can be found in the MATH_CONSTANTS package where it is usually referred to as EXP1 (but not for all compilers!).
You should hand in a report comprising the following sections:
Marks distributed evenly between: design, implementation and testing. Refer to guidance notes on the presentation of work if necessary.
Created and maintained by Frans Coenen. Last updated 11 October 1999