Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Programming in C Biased Coin Problem

Write a simulator in which one round of simulation involves flipping a set of ten unfair coins (or the same unfair coin ten times) in which there is a fixed likelihood of any given flip coming up heads.

The result of each round is the number of times that a head appeared, so if in a particular round there were four heads, the result for that round would be four.

You will ask the user for the bias (the percentage chance that a coin will come up heads) and for the number of rounds to perform.

After running the simulation you will report how many times each outcome resulted as well as the percentage of the time it occurred.

Your output should look very similar to the following (in particular, it should be well formatted):

What is the coin bias (percent chance of coming up heads)? 75

How many rounds? 1000000

COINS..... 10
BIAS...... 75.00%
ROUNDS.... 1000000

SUM ROUNDS PERCENTAGE
0    0             ( 0.00% )
1       24            ( 0.00% )
2      360           ( 0.04% )
3     3187          ( 0.32% )
4    16221         ( 1.62% )
5    58108         ( 5.81% )
6   146347        ( 14.63% )
7   249823        ( 24.98% )
8   281878        ( 28.19% )
9   187655        ( 18.77% )
10 56397          ( 5.64% )

Add a histogram to the output.

Following each line in the report you will print out a line of asterisks whose length is proportional to the percentage of the time that result came up. If the frequency was less than 1%, do not print any asterisks.

Then print an additional asterisk for each additional two percentage points (so the boundaries should be odd percentage points).

What happens should an amount fall exactly on the boundary (say 53% exactly) is not important as far as whether a new asterisk is added or not.

The output should now look something like:

What is the coin bias (percent chance of coming up heads)? 63.4

How many rounds? 10000

COINS..... 10
BIAS...... 63.40%
ROUNDS.... 10000

SUM ROUNDS PERCENTAGE
0       0               ( 0.00% )
1       7               ( 0.07% )
2      57              ( 0.57% )
3     261             ( 2.61% )   *
4     822             ( 8.22% )   ****
5     1765           ( 17.65% ) *********
6     2436           ( 24.36% ) ************
7     2372           ( 23.72% ) ************
8    1604            ( 16.04% ) ********
9     572               ( 5.72% ) ***
10   104               ( 1.04% ) *

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93095379

Have any Question?


Related Questions in Computer Engineering

Question in sql database hospital systems suffer from 4-10

Question : In SQL Database, Hospital Systems suffer from 4-10% duplicate patients in the EHR. Some is that patients do not know the relationships of medical facilities in the same organization. What can you do to identif ...

Suppose you had the following backup plan full backups on

Suppose you had the following backup plan: Full backups on the first Sunday of every month, differential backups on the other Sundays of the month, and incremental backups M-F. Suppose something bad happened on April 26t ...

Questionsuppose we are comparing implementations of

Question Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size n, insertion sort runs in 8n2 steps, while merge sort runs in 64nlgn steps. For which values of n ...

Can someone help me with traceroute of massachusettsnbspuse

Can someone help me with traceroute of massachusetts  Use traceroute to trace the route from your home or work computer to your university's website. Show the traceroute output. What networks were encountered along the w ...

Regarding terminology for the quality of a picture explain

Regarding terminology for the quality of a picture, explain briefly What is a pixel? What is color depth? Higher is better or lower Search for purchasing a monitor, list the specifications (concentrate on the criteria th ...

A group of adult males has foot lengths with a mean of 2693

A group of adult males has foot lengths with a mean of 26.93 cm and a standard deviation of 1.12 cm. Use the range rule of thumb to identify the limits separating values that are significantly low or significantly high. ...

Question process designoperations management involves

Question: Process Design Operations management involves various activities, such as process design, selection, management of information technology, work systems, planning and development, and quality assurance (Slack, C ...

Explain why some organizations may not place enough

Explain why some organizations may not place enough importance on disaster recovery. What might happen to these organizations in the event of an actual disaster?

Video and disruption report assignmentoverviewfor this

Video and Disruption Report Assignment Overview For this assessment task, you will create a two-minute video and written proposal about the impact of a particular technology on an industry or field. The purpose of this a ...

Imagine youve started a new pizza restaurant it costs you

Imagine you've started a new pizza restaurant. It costs you about $6 to produce a pizza. Last week you sold 500 pizzas for $12 each. This week you raised your price and sold 375 pizzas for $14 each. What price should you ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As