Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 CMPE571 Systems Modelling and Simulation Fall 2021 Mini Project MP-1 Date: Tue., 07/12/2021 Due Date: Tue., 04/01/2022 1. Objective The objective of this homework

image text in transcribed

image text in transcribed1 CMPE571 Systems Modelling and Simulation Fall 2021 Mini Project MP-1 Date: Tue., 07/12/2021 Due Date: Tue., 04/01/2022 1. Objective The objective of this homework is to help students to understand and enable: (i) Pseudo Random Numbers (PRN) and their generation (ii) Generation of Uniformly Distributed RNs (iii) Generation of Random Variates (RVs) [Interarrival and Service Times] (iv) How to evaluate Random Numbers (v) Use of an ANSI C library functions (vi) Development and use of multi-file C programs. 2. Problem Write a series of C programs as indicated below to generate pseudo-random numbers, check pseudorandom numbers, generate uniformly distributed random numbers, IATs and Service Times and evaluate IAT and service times. Use the provided ANSI C library by Steve Park and Dave Geyer[1][2]. You are required to complete the following: 1. Generate Pseudo Random Numbers. 2. Generate 10 seeds 20,000 numbers apart. 3. Generate Uniformly distributed Random Numbers: U[0.0-1.0]. 4. Generate IATs. 5. Generate Service Times. 6. Evaluate IAT and Service Times (1). 7. Evaluate IAT and Service Times (2). 3. The Technique Your programs should be modular and structured (monolithic programs will loose marks). The preferred technique is to write software with multi-file C programs and compiled through the make facility on Cygwin or using the Project facility of the DevC++ IDE. 3.1 Generate Pseudo Random Numbers: i) Write a C program named random.c to be compiled to have the name: random (or random.exe). You should compile your program with the ANSI C library provided[2] so that you can use the four library functions provided: double Random(void), void GetSeed(long *x), void PutSeed(long x), and void TestRandom(void) in your program (Hint: library functions are in the rng.c file). ii) Select the seed of: 987654321L (this is the DEFAULT2 value; but alternatively, you can initialise your RN generator with this seed). iii) Your program should generate SSIZE (Sample Size) number of random numbers and place them in the text file called: out.txt. - Notes: a) There should be only one number per line. b) Generate 1,000 pseudo random numbers c) Rename the output file out.txt as randnos1.txt . 3.2 Generate 10 Seeds 20,000 Random Numbers apart: i) Modify your program in (3.1) renaming it as seeds.c. Generate and print 10 seeds (NSEEDS) which would be 20,000 random numbers (SSIZE) apart, into a file called seeds.txt. Generate 10 seeds each 20,000 numbers apart from each other and write the seed found into a file called seeds.txt starting with the initial seed of 1573301349, such that the output is as follows: 2 seed 0: 1573301349 seed 1: xxxxxxxxx seed 2: yyyyyyyyy .. Seed10: zzzzzzzzzz 3.3 Generate Uniformly distributed Random Numbers: i) Modify your program in (1) above and rename it as uniform.c; to be compiled to have the name: uniform (or uniform.exe) . ii) Your program should generate uniform random numbers (in the range 0.0 RN 1.00). iii) Use starting (DEFAULT2) seed value of 987654321L and generate 1,000 uniform RNs. Copy the out.txt file to place the results in a file called uniform.txt. NOTE: As these numbers will correspond one to one to those Random Long Integer values generated in step (3.1), one can combine the (3.1) and (3.3) as one program but with two outputs: out1.txt and out2.txt respectively. In this case, out1.txt could contain the long integer values and out2.txt could contain the corresponding uniform random numbers in the range 0.0 to 1.0. 3.4 Generate IATs: i) It is required to generate IATs of 2, 6, 8 and 10 seconds with frequency of occurrence of 30%, 25%, 30% and 15% respectively. ii) Write a program in C which will be named gen_iat.c which will be compiled to be named gen_iat (or gen_iat.exe). Generate 1,000 IATs. Write the generated IATs into the output file to be named: iat.txt. Use starting seed of: 1573301349L (given in rng.c). 3.5 Generate Service Times: i) It is required to generate Service Times (Ts) of 1, 3, 5 and 7 seconds with frequency of occurrence of 12%, 40%, 30% and 18% respectively. ii) Write a program in C which will be named gen_ts.c which will be compiled to be named gen_ts(or gen_ts.exe). Generate 1,000 Service Times. Write the generated Service Times into the output file to be named: ts.txt. Use starting seed of: 1573301349L (given in rng.c). 3.6 Evaluate IAT and Service Times (1): i) It is required to evaluate the generated IATs. Using appropriate bins, verify that the generated IAT times of 2, 6, 8 and 10 seconds with frequency of occurrence of 30%, 25%, 30% and 15% respectively. ii) It is required to evaluate the generated Service Times. Using appropriate bins, verify that the generated Service Times of , 3, 5 and 7 seconds with frequency of occurrence of 12%, 40%, 30% and 18% respectively. iii) Write two separate C programs to open and read the iat.txt and the ts.txt files respectively. In each case, count the number of different IATs and Service Times using different bins. Calculate the frequency of occurrence of each bin type and print out the results on the screen. iv) Comment on any discrepancies between the theoretical and practical values. 3.7 Evaluate IAT and Service Times (2): i) Repeat the experiments 3.4, 3.5, and 3.6 with 20,000 random numbers and check that a better fit is obtained between the theoretical and practical values. 4. Deliverabes Submit a short report for your results. Also include an explanatory README.txt file which should explain how file names (as answers) map to sections (questions/sections), source codes, executables, input and output data files (appropriately named). For sections 3.6 and 3.7, please note that you should use a table to compare the theoretical expectations and the observed (experimental) values. Please also comment on your results. 3 5. Effort Type This homework can be done individually or in a group of 2 students. Students should send e-mail indicating the members of each group. 6. References 1. Steve Park and Keith Miller, Random Number Generators: Good Ones Are Hard To Find, Communications of the ACM, October 1988. 2. Steve Park and Dave Geyer, ANSI C Library for Random Number Generation; (rng.h and rng.c). 7. Appendix A Steve Park and Dave Geyer ANSI C Library [2]: Files are: rng.h and rng.c These are two files provided as an ANSI C library for random number generation. This library is recommended as a replacement for the ANSI C rand() and srand() functions, especially for applications where statistical 'goodness' of the random number generator is important. The generator used in this library is a so-called Lehmer random number generator which returns a pseudo-random number uniformly distributed between 0.0 and 1.0. The period is (m - 1) where m = 2,147,483,647 and the smallest and largest possible values are (1 / m) and 1 - (1 / m) respectively. For more details see [1]. Functions available are: double Random(void) : This is a Lehmer generator that returns a pseudo-random real number uniformly distributed between 0.0 and 1.0. void GetSeed(long *x): This is an optional procedure to get the current state of the random number generator; i.e. the current seed to be used. void PutSeed(long x) : This is an optional procedure to initialize or reset the state of the random number generator according to the following conventions: if x > 0 then x is the initial seed (unless too large) if x

Please I need solution with MATLAB CODE programming

1. Objective The objective of this homework is to help students to understand and enable: 1) Pseudo Random Numbers (PAN) and their generation (0) Generation of Uniformly Distributed RNS (4 Generation of Random Variates (RV) interarrival and Service Times (iv) How to evaluate Random Numbers Use of an ANSI C library functions (v) Development and use of multi-file "C" programs 2. Problem Write a series of programs as indicated below to generate pseudo-random numbers, check pseudo random numbers, generate uniformly distributed random numbers, Ats and Service Times and evaluate IAT and service times. Use the provided ANSI C Ibrary by Steve Park and Dave Geyer[112]. You are required to complete the following: 1. Generate Pseudo Random Numbers 2. Generate 10 seeds 20,000 numbers apart 3. Generate Uniformly distributed Random Numbers: U10.0-10 4. Generate IATS 5. Generate Service Times 6. Evaluate IAT and Service Times (1) 7 Evaluate IAT and Service Times (2) J. The Technique Your programs should be modular and structured monolithic programs will loose marks) The preferred technique is to write software with multi-file" programs and compiled through the make facility on Cywin or using the Project facility of the DevC++ IDE 3.1 Generate Pseudo Random Numbers: Write a " program named "random.c" to be compiled to have the name:"random for random.exe) You should compile your program with the ANSI C library provided 2 so that you can use the four library functions provided double Random(void), vold GetSeedflong void Putseeding and void TestRandom(void) in your program (Hint: library functions are in the mo.c file) 1) Select the seed at: "987654321L" (this is the DEFAULT value, but alternatively, you can initialise your : " RN generator with this seed). ii) Your program should generate "SIZE" Sample Size) number of random numbers and place them in the text file called: out.txt Notes: a) There should be only one number perline b) Generate 1,000 pseudo random numbers Rename the output file out at asrodnost. Dat 3.2 Generate 10 Seeds 20,000 Random Numbers apart: W Modify your program in (3,1) renarning it as "seeds. Generate and print 10 seeds INSEEDS) which would be 20,000 random numbers (SIZE) apart, into a file called seeds.bt. Generate 10 seeds each 20.000 numbers apart from each other and write the seed found into a file called seeds.but starting with the initial seed of 1573301349, such that the output is as follows 1 seed: 1571301349 seed 1. DOO seed 2: WWWW Seed10:22222222 zumn 2.3 Generate Uniformly distributed Random Numbers: Modify your program in (1) above and rename it as "uniform.c; to be compiled to have the name: "uniform for uniform.exe) :) Your program should generate uniform random numbers in the range 0.0 SANS 1.001. Use starting (DEFAULT) seed value of 9876543211" and generate 1,000 uniform RNs. Copy the out file to place the results in a file called 'uniform.txt" NOTE: As these numbers will correspond one to one to those Random Long Integer valuss generated in step (3.1). One can combine the (3.1) and (3.3) as one program but with two outputs: out1.but and out2.txt respectively. In this case, out1.but could contain the long integer values and out2.txt could contain the corresponding uniform random numbers in the range 0 to 10. 3.4 Generate IAT: 0 it is required to generate tAts of 2, 6, 8 and 10 seconds with frequency of occurrence of 30%, 25%. 2, 8 30% and 15% respectively. Write a program in which will be named "en_iate which will be compiled to be named "gen_tat" (orgen for eve). Generate 1,000 IATS Write the generated IATS into the output file to be named: iturUse starting seed of: "1573301349" (even in mec. 3.5 Generate Service Times: : 0 it is required to generate Service Times (73 of 1, 3, 5 and 7 seconds with frequency of occurrence of 7 12%, 40%, 30% and 18% respectively. Write a program in which will be named "gen_ts.c" which will be compiled to be named "" "gen_ts" or gen_ts.exe). Generate 1,000 Service Times. Write the generated Service Times into the output file to be named "stat". Use starting seed of "1573301349" (given in mec). 3.6 Evaluate LAT and Service Times (1): 1 It is required to evaluate the generated (AT. Using appropriate bins verity that the generated IAT times of 2 6.8 and 10 seconds with frequency of occurrence of 30% 25% 30% and 15% seconds wenty respectively. 15) It is required to evaluate the generated Service Times. Using appropriate bint verify that the generated Service Times of 3.5 and 7 seconds with frequency of occurrence of 12%, 40%, 30% and 18% respectively 1) Write two separate programs to open and read the it. But and the ts.txt files respectively. In each case, count the number of different tATs and Service Times using different bins Calculate the frequency of occurrence of each bin type and print out the results on the screen iv) Comment on any discrepancies between the theoretical and practical values. 3.7 Evaluate SAT and Service Times (2) Repeat the experiments 34, 35, and 1.6 with 20,000 random numbers and check that a better fit is obtained between the theoretical and practical values. 4. Deliverabes Submit a short report for your results. Also include an explanatory README.txt file which should explain how file name as answers) map to section (questions/section), source codes, executables. Input and output data files (appropriately named). For sections 3.6 and 3.7. please note that you should use a table to compare the theoretical expectations and the observed (experimental) values. Please also comment on your results 5. Effort Type This homework can be done individually or in a group of students. Students should send e-mail 2 indicating the members of each group 6. References 1. Steve Park and Keith Miller, Handom Number Generators: Good Ones Are Hard To Find, Communications of the ACM, October 1988 2. Steve Park and Dave Geyer, "ANSI C Library for Random Number Generation":(mehi and mec), 7. Appendix A Steve Park and Dave Geyer ANSIC Library 121: Files are: mg.h and rng.c These are two files provided as an ANSI C library for random number generation. This library is recommended as a replacement for the ANSI C rond) and sandf) functions, especially for applications where statistical Hoodness of the random number generator is important The generator used in this library is a so-called "Lehmer random number generator which returns a pseudo-random number uniformly distributed between 0.0 and 1.0. The period is (m. 1) where m= 2,147,483,647 and the smallest and largest possible values are (1 m) and 1 - (1/m) respectively. For more details see (1) Functions available are: double Randomtvold) : This is a lehmer generator that returns a peudo-random real number a uniformly distributed between 0.0 and 1.0. void GetSeed long ex}: This is an optional procedure to get the current state of the random number generator, le the current seed to be used. void PutSeed long x) : This is an optional procedure to initialize or reset the state of the random number generator according to the following conventions then is the initial seed (unless too large) Hxc then the initial seed is obtained from the system clock if then the initial seed is to be supplied interactively void TestRandom(void): This is an optional procedure to test for a correct implementation Notes: : 1) Use Testtandoml) to check if the Random Number Generator is OK 2) Use Gereed) to obtain the Random Number (as a long integer ind. You can then print this value into a file to obtain a series of Random Numbers 3) Use PutSeedtiff you want to start with a new seed. Otherwise do not need to use it except . for checks that it and GetSeed works, 4) Use landom) to get a real number distributed uniformly between 0.0 and 10 5, " 5) Notice that if you do not set the seed, it is set to the DEFAULT value of 987654321L" 8. Appendix B This appendis describes the TPG.rar facility provided to demonstrate the use of the Park & Geyer Random Number generator functions and their use. Please also note that it also provides an example of single and multi-file" program use under Windows DevC++) and Linux/Orgwin (under Windows. Please study it to see the use of either form and the use of the mgh and mic library files 1. Program called "TPG.c": a simple standalone program with a main() provided as part of the moc renamed as TPG.C 2. Program called "TPGng.c": a separate file that has main() to run with the mgc and my he library. It can be compiled using ece or the makefile provided under Linux or Cygwin (Alternatively under the Project facility of the DevC++) 3 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

What are the major determinants of the elasticity of demand?

Answered: 1 week ago