Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Random number generator. In this problem, you will code a random number generator that you can use throughout this course in various programming assignments.

image text in transcribed
1. Random number generator. In this problem, you will code a random number generator that you can use throughout this course in various programming assignments. See comments at the end of this problem. A. Using a computer language of your choice, write a random number generator using the general multiplicative congruential algorithm. Print out the parameters I1, and M. Further, print out the first 50 random numbers in a table with headers as follows: n K(n R 0 K(0) R. 1 K(1) R Remember that the table must start with n = 0 and K(0) = seed. B. Test that the generated random numbers are uniformly distributed between 0 and 1 by setting up 10 equally sized bins and tally the bin frequency for adequately large number of random numbers, as follows. Generate 100, 1000, and 10 000 random numbers and for each case print out the number of random numbers in bins 1 to 10. - Determine in each case whether the random numbers are evenly distributed across the bins by performing the (a) moments test and (b) the frequency test. Recall that the congruential algorithm is: R. = K(n)/M , where K(n) is an integer computed from the previously generated number K(n-1), as follows: K(n) = MOD[ 11*K(n-1)+12, M). In the multiplicative congruential algorithm 12=0. MOD is the Modulo function in FORTRAN, which generates the remainder of the ratio of two integer numbers. Similar functions are available in other computer languages. For seed, K(0) is chosen between 0 and M-1. A fairly high value for M - 10' and I1 7' will give good results. You can test multiple values to see the uniformity. 1. Random number generator. In this problem, you will code a random number generator that you can use throughout this course in various programming assignments. See comments at the end of this problem. A. Using a computer language of your choice, write a random number generator using the general multiplicative congruential algorithm. Print out the parameters I1, and M. Further, print out the first 50 random numbers in a table with headers as follows: n K(n R 0 K(0) R. 1 K(1) R Remember that the table must start with n = 0 and K(0) = seed. B. Test that the generated random numbers are uniformly distributed between 0 and 1 by setting up 10 equally sized bins and tally the bin frequency for adequately large number of random numbers, as follows. Generate 100, 1000, and 10 000 random numbers and for each case print out the number of random numbers in bins 1 to 10. - Determine in each case whether the random numbers are evenly distributed across the bins by performing the (a) moments test and (b) the frequency test. Recall that the congruential algorithm is: R. = K(n)/M , where K(n) is an integer computed from the previously generated number K(n-1), as follows: K(n) = MOD[ 11*K(n-1)+12, M). In the multiplicative congruential algorithm 12=0. MOD is the Modulo function in FORTRAN, which generates the remainder of the ratio of two integer numbers. Similar functions are available in other computer languages. For seed, K(0) is chosen between 0 and M-1. A fairly high value for M - 10' and I1 7' will give good results. You can test multiple values to see the uniformity

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

Step: 3

blur-text-image

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

8.10 Explain several common types of training for special purposes.

Answered: 1 week ago