Java Reference
In-Depth Information
When run, this program produced the following output:
Simulation Caps collected
1 10
2 10
3 22
4 12
5 36
6 9
7 15
8 7
9 11
10 70
11 17
12 12
13 27
14 10
15 6
16 25
17 8
18 7
19 39
20 71
Average caps per simulation: 21
The results range from as few as 6 caps to as many as 71. Sometimes you get lucky, sometimes you don't.
Each time the program is run, it will produce different results.
6.8 Simulation of Real-Life Problems
The computer can be used to answer certain questions about many real-life situations by using simulation . The process
of simulation allows us to consider different solutions to a problem. This enables us to choose, with confidence, the
best alternative for a given situation.
However, before the computer simulation is done, we need to collect data to enable the simulation to be as
realistic as possible. For example, if we want to simulate serving customers at a bank, we would need to know (or at
least estimate) the following:
The time,
t1 , between arrivals of customers in the queue
The time,
t2 , to serve a customer
Of course, t1 could vary greatly. It would depend, for instance, on the time of the day; at certain times, customers
arrive more frequently than at other times. Also, different customers have different needs, so t2 would vary from one
customer to the next. However, by observing the system in operation for a while, we can usually make assumptions
like the following:
t1 varies randomly between one and five minutes.
t2 varies randomly between three and ten minutes.
 
Search WWH ::




Custom Search