Write a single code, randtest.c, that uses the instruction

Assignment Help C/C++ Programming
Reference no: EM133243473

Distribution of Software Generated Pseudo Random Numbers

Specification

This is the element A.1 with a ratio of 25% of the overall module assessment. It consists in writing test programs in C programming language to assess the quality of a simple pseudo random number generator based on the rand() function of "stdlib.h". Please notice that in this task we are NOT seeking generating real random numbers but just interested in investigating the distribution of pseudo random numbers generated. The tests you are going to implement were theoretically suggested by Kendall & Babbington-Smith over a series of papers published in 1938/39.

The rand() function returns a pseudo-random integer between 0 and RAND_MAX, which is defined in stdlib.h. You should NOT replace it with a constant since its value may vary with platforms. You need to rescale this value and fit it between 0 and 10 (0 included, 10 excluded). To generate a single pseudo random number between 0 (included) and 10 in your code, you must use the following: randon_number=(int)(10.0*rand()/(RAND_MAX+ 1.0));

Please notice it is required to use this instruction for all number generation instructions, so do not make any change of this. Also, do NOT use or make change to the random variable generator seeds. This may result in different distribution and failure to pass the tests.

Write a single code, randTest.c, that uses the instruction above to generate every single number and implements all the tests given in table 2. Use the parsing command line arguments through the main function (with a single character parameter after the file name) to select and perform a single test in the runtime. E.g., suppose the executable file is named, ranTest.out, if in the runtime one wishes running the first test, they just have to type "ranTest.out 1", if the second, "ranTest.out 2", etc. Notice it is a requirement to use gcc and the MSc cyber program VM to develop this code. Please refer to week 1 material for that.

Test

Deception

1. Mean test

Calculate and display the mean of 1000 random numbers. The result should be close to

4.5.

2. Frequency test

Tabulate the percentage of each digit (0 throughout 9) in 10,000 generated numbers.

Each Is expected to be close (roughly) to 10%.

3. Serial test

Generate 10,000 pairs of numbers. Tabulate the percentage of each pair, 00, 01,02, .....,

99. This time we would expect roughly 1% in each category.

4. Poker test

Generate four digits at a time, and repeat 1,000 times (a thousand sets of 4 digits in total). Tabulate the cardinalities of the sets (the four digit tuples) as: i) all the same (e.g. 4444), ii) 3 digits the same (e.g. 4443, 3444 or 4344), iii) two pairs (e.g. 4334, 4433), iv) one pair (e.g. 4324 or4342), or v) none identical. In theory we would expect 1, 36, 27, 432 & 504 for each set respectively for a thousand sets of numbers (i.e., 4,000 digits).

You will not necessarily get those exact numbers.

5. Pocker Test using a file

Generate 4,000 random digits and save them in a text file (using ASCII coding), where

characters are separated by spaces and each line includes four characters. Repeat the poker test by reading the numbers from the file.

Reference no: EM133243473

Questions Cloud

Understand in relation to job analysis : KSAOs in particular - understand in relation to job analysis and how each job will have varied characteristics.
What are the admit diagnosis and principal diagnosis : What are the ICD-10-CM/ICD 10 PCS, Admit diagnosis and principal diagnosis and any secondary diagnoses
Growth Team performance : What specific recommendations for enhancing the Growth Team performance would you make? Why?
What coding systems are used in the united states : What is medical coding and what is it used for? What coding systems are used in the United States? How do changes in ICD-9 over the years reflect events
Write a single code, randtest.c, that uses the instruction : Write a single code, randTest.c, that uses the instruction above to generate every single number and implements all the tests
How a physician practice communicates with hospital : Explain how a physician practice communicates with the hospital to foster high-quality, efficient, and effective patient care
Develop data-driven approach to selection in companies : What types of skills will HR professionals need to develop a data-driven approach to selection in companies?
Why change management is so difficult for most people : Question - When writing this essay gives a rationale of why Change Management is so difficult for most people
How have ethics and laws around medical research : How have ethics and laws around medical research with human subjects changed? How is the medical community viewed today

Reviews

len3243473

10/13/2022 10:53:27 PM

Hello, I have a little assignment in C programming. I need you to help me to do this assignment. This is five tasks and all tasks are easy I am pretty sure you can do this. Note: don''t copy from anywhere, provide your own logic and if possible provides references. provides links with every task if you take something from the internet.

Write a Review

C/C++ Programming Questions & Answers

  Program to build tax calculator

I need a C program that will address the application requirements called out in this Service Request: "SR-kf-008, Tax Calculator"

  Create a square using the tangram pieces

Explain your design and implementation process and any challenges you came across, as well as how they were overcome at the end

  Write a function that will return the area of a trapezoid

Write a function that will return the area of a trapezoid - Write a function that will return the perimeter of a trapezoid

  Write code to count how many times the string hello

Create a cell array, C, containing the strings: 'hello' 'goodbye' 'hello' 'hello goodbye' 'goodbye' 'hello' 'goodhellow' 'see you in hell'.

  Develop a new program that simulates the hiring

Develop a new program that simulates the hiring and processing of new employees for your company. The queue should be a First In First Out(FIFO) based queue

  Implement a selection sort

Implement three functions whose prototypes are given - You are going to use a static array declared using { 12, 1, 6, 8, 5, 9, 22, 9, 13, 17 } to initialize an STL list, as shown in the slides.

  Difference between a constant pointer

Explain the difference between a constant pointer to non-constant data and a non-constant pointer to constant data. Show the syntax to declare them.

  Write a program to calculates large factorials

Write a driver program to test your modified class Begin with the multiplication operation * added in Exercise.

  Determines the average length of the words in a sentence

Write a second function that determines the average length of the words in a sentence.

  Write a c program to enter the numbers until the user wants

Write a C program to enter the numbers until the user wants and in the end display the product of numbers entered by the user.

  Write program using data abstraction to track stock market

Topic: C++ Assignment. You have decided to write a C++ program using data abstraction to help you keep track of the stock market

  Calculate the number of monthly payments

Third, multiply the number of years in the term of the mortgage by 12 to calculate the number of monthly payments you'll make

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd