Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a c program that will simulate the following random events using the rand( ) function in the C standard libraries. We are interested in

 Write a c program that will simulate the following random events using the rand( ) function in the C standard libraries. We are interested in determining if rand( ) really seems to produce a random set of values. To do this we will repeat the event a certain number of times and see how often we get each of the possible results. If rand( ) is truly random, and our mapping to the possible results is uniform, our results should be equally likely and therefore evenly distributed across all possible results. We will simulate the following three events: 1) Flipping a coin 2) Rolling a six-sided die 3) Drawing one particular card from a shuffled deck of 52 cards, for example the Ace of Spades Repeat each event: 1) 10 2) 100 3) 1000 4) 10,000 5) 100,000 times Within each set of repetitions, count how often each result occurs. Then compute the percentage of the total events were represented by each result. Ex: Coin: ---- Flips: 10 Heads: 40% Tails: 60% Die: ---- Rolls: 10 1: 10% 2: 0% 3: 20% 4: 30% 5: 30% 6: 10% Card: ---- Draws: 10 Card wanted: 0% Not card wanted: 100% ... Coin: ---- Flips: 100000 Heads: 49% Tails: 51% Die: ---- Rolls: 100000 1: 17% 2: 18% 3: 17% 4: 17% 5: 17% 6: 16% Card: ---- Draws: 100000 Card wanted: 2% Not card wanted: 98% 

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

Are there any caveats regarding goal setting?

Answered: 1 week ago

Question

Explain the purposes of managing performance.

Answered: 1 week ago

Question

List 4 methods to evaluate training.

Answered: 1 week ago