Sie sind auf Seite 1von 8

QUESTIONS (1) Briefly explain any three common techniques used to generate random numbers (6mks) (2) Consider

simulating a single server queue; identify the exogenous and endogenous variables (4mks) (3) (i) what are the areas different in simulation languages(3mks) (ii) What are the standard capabilities (3mks) (4) There are ten people in an office of which any one of them can talk on his/her phones any minute with a probability of 0.7. Write statements to simulate this situation and identify the number of people who will be on phone between 9.00 am to 9.30 am (4mks) (5) Differentiate between logical and physical models (3marks) (6) Briefly discuss the different kinds of simulations (2mks) (7) What are the desired properties of a good random numbers generator (4mks) (8) Name any three statistical tests for randomness (3mks) Answers (1) (i) The Direct Method We directly use the definitions of the desired distributions from which we are to generate the random numbers. This is easily achieved by in-built functions in simulation packages e.g in MATLAB we have a function RAND that generates uniformly distributed random numbers, RANDN: from standard normal distribution, BINORND: from binomial distribution. (ii) The Inverse Transform Method This method is applied only to cases where the cumulative density function, F(X), can be inversed analytically. First a random number say, r, is generated and is set to F(X) i.e r=F(X).

The quantity X is then obtained by inverting F i.e X=F-1(r) (iii) The rejection method Used to generate random numbers if the distribution, f(x), is bounded, and X is finite.
(a) Select c, such that c*f(x) (b) Generate r1, and set X= r1 (c) Generate r2, if r2< c*f(r1). Then accept r2 otherwise, go back to step (b) above.

(2) Exogenous variables i) ii) iii) iv) The time interval between two successive arrival The service time of a customer Number of servers Priority discipline

Endogenous variables i) ii) mean waiting time in the queue mean number of customers in the queue

(3) (i) areas of different include Construction Logic Ease of usage Accessibility Flexibility

(ii) standard capabilities include Structured data input

Echo checks or error checks for program input and logic structure Random number generators Automatic statistical generator functions A variety of random deviate generators Standard simulation output of relevant data and simulation statistics Ease of usage Proper documentation and instruction for any user

(4)student to relate this event to that of tossing a coin Number =0; %number of people on phone For i=1:30 ;%duration of time. set simulation for ten people K=1:10; R=rand; If R (K,i)<0.7 ; %on phone Number =Number+1 Else Number =0; %not on phone End End (5) find the differences from the notes (6) (i) Continuous simulation concerns the modeling over time of a system by a representation in which the state variable change continuously with respect to time. Such models typically

involve differential equations that give relationships to the rates of change of the state variables with time. (ii) Combined dicrete-continiuous simulation: Since some sytems are neither completely discrete nor completely continuous, the need may arise to construct a model with aspects of both. (2mks) (iii) Monte carlo simulation is a scheme for employing random numbers to define the aspects of uncertainty in systems (7) Desired properties of a good random number generator The generator should be fast The generated numbers should have as nearly as possible a uniform distribution The generator program should not realize large number of core The generator should have a large period i.e produce a long sequence of numbers before the sequence begins a cycle The generator should not produce a zero The method should not degenerate to repeatedly produce a constant value The generator should be able to produce a different set of random numbers to reproduce a series of numbers depending on where it starts the sequence. (8) (i)Frequency test (ii) serial test (iii) run test (iv) autocorrelation test (v) chi-square test

QUESTIONS SIMULATION AND MODELING (1)What are the advantages for using simulation other than experimenting with real life systems? (5mks) (2) in a queue system, given that L denote the number of customers in the system, denotes the arrival rate , denote service rate, W denotes the waiting time in the system, Lq and Wq denotes the number of customers in the queue and waiting time in the queue respectively. Give expressions that represent (i) L in terms of and W (1mk) (ii) Lq in terms of and Wq (1mks) (iii) (iv) W in terms of Wq and (2mks) L in terms of and (2mks)
(3) what does a M/M/1 model represent?(1 mark)

(4) Discuss any two statistical techniques used to test for randomness when pseudorandom numbers are generated (4mks)

(5) Write statements (algorithm) in MATLAB on how to simulate unfair coin, with probability of getting a head as 0.6, 100 times and record the resulting number of heads and tails (4mks)

Answers (1) Advantages for using simulation are To verify analytical solutions To study dynamic systems in either real time, compressed time or expanded time To identify bottlenecks and other problems that may arise in a newly introduced system To serve as a preservice test To experiment with new situations about a system we have little or no information Use as a pedagogical(instructional) device in training and teaching For better understanding of the system To study and experiment with complex interactions within a system

(2) Littles formulae (i) L=W (ii) Lq=Wq (iii) W=Wq+1/ (iv) L=Lq+/ Similarly you can express in terms of measures of performance. (3) M/M/1 model means

(i) (ii) (iii)

Arrival rate and service time is markovian or memory less. There is only one server. Infinite population size

(4) (i) Frequency test

Is the most fundamental test for pseudo-random numbers. If for pseudo-random numbers fails this test, then it is highly likely that it will also fail more sophisticated tests. It is based on the fact that on a true random sequence the number of 1s and 0s should be the same. This test checks whether this is true or not. This is achieved by using a complementary function (erfc) in MATLAB or JAVA. (2 MARKS) (student can as well highlight the steps involved in computing the test statistics, or give an example) ii) Serial test

This is based on the different ways of combination the number of bits occurring. Each bit has the same chance of occurring if the sequence of the k-bits is random. The serial test determines whether the number of times each of these combination occurs is uniformly distributed. It further checks the randomness of overlapping blocks in a sequence. (i) Runs test

Used to test the assumption that the pseudo-random numbers are independent of each other. Starting with a sequence of pseudo-random numbers in[0,1], we look at for unbroken subsequence of numbers, where the numbers within each subsequence are monotonically increasing. Such a subsequence is called a run up and it may be as long as one number.

(5) head =0; Tail =0; For i=1:100 R=rand; If R<0.6 Fprintf (head); Head=head+1; Else Fprintf(Tail); Tail=tail+1; End End Head %to get the number of heads Tail %to get the number of tails