Program that accepts the number of darts as an input

Assignment Help Basic Computer Science
Reference no: EM131305075

Monte Carlo techniques can be used to estimate the value of pi. Suppose you have a round dart board that just fits inside of a square cabinet. If you throw darts randomly, the proportion that hit the dart board vs. those that hit the cabinet (in the corners not covered by the board) will be determined by the relative area of the dart board and the cabinet. If n is the total number of darts randomly thrown (that land within the confines of the cabinet), and h is the number that hit the board, it is easy to show that

2427_cfd90810-4b46-4411-8fd7-3a36ea2699f4.png

Write a program that accepts the "number of darts" as an input and then performs a simulation to estimate π. Hint: you can use 2*random() - 1 to generate the x and y coordinates of a random point inside a 2x2 square centered at (0, 0). The point lies inside the inscribed circle if x2 + y2 ≤ 1.

Reference no: EM131305075

Questions Cloud

Analyze the legal rights and responsibilities of the tenant : Explore the legal rights and responsibilities of the tenant and the landlord. Decide whether or not the landlord and / or the tenant had a legal duty to mitigate damages.
Performs a simulation to estimate the probability of rolling : Suppose you take a random walk of n steps. On average, how many steps away from the starting point will you end up? Write a program to help you investigate this question.
Credit risk file based on different types of loans : Describe how to apply stratified sampling to sample from the Credit Risk file based on the different types of loans. Implement your process in Excel to choose a random sample consisting of 10% of the records for each type of loan.
What is a banks net interest margin : What is a T-account? Use a T-account to show the effect on Bank of America's balance sheet of your depositing $50 in currency in your checking account.
Program that accepts the number of darts as an input : Write a program that accepts the "number of darts" as an input and then performs a simulation to estimate π. Hint: you can use 2*random() - 1 to generate the x and y coordinates of a random point inside a 2x2 square centered at (0, 0). The point l..
Dividend policy can also be considered irrelevant : Modigliani & Miller show that dividend policy can also be considered irrelevant. Yet, unexpected increases in dividends are often closely followed by price increases, why? To clarify, when a firm pays a dividend the stock price should drop by the amo..
Why might banks shareholders want bank to be less leveraged : Why might the managers of a bank want the bank to be highly leveraged? Why might the bank's shareholders want the bank to be less highly leveraged?
How you would motivate the student to perform in class : Identify which of Maslow's need(s) each student is trying to fulfill. Explain how you would motivate the student to perform in class.
How the balance sheets of each bank will be affected : Suppose that Lena, who has an account at SunTrust Bank writes a check for $100 to José, who has an account at National City Bank.- Use T-accounts to show how the balance sheets of each bank will be affected after the check clears.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Contrast crystallized versus fluid intelligence

Compare and contrast crystallized versus fluid intelligence. Give an example of each form of intelligence 3 paragraphs.

  Are these difficulties true for all types of scatter plots

How many independent variables can be depicted in a scatter plot? What are some of the difficulties in visualizing data in a scatter plot? Are these difficulties true for all types of scatter plots? Suggest alternatives for overcoming these limita..

  Recommend for naming files in business

What kinds of rules would your recommend for naming files in business? For personal use?

  Write a report suggesting appropriate metrics

Write a report suggesting appropriate metrics and suggest how these can be collected.

  Find the volume of the solid

Find the volume of the solid that lies under the paraboloid z=x2 + 4y2 and above the region D in xy-plane bounded by the line y=3x and the parabola y=3x2.

  Describe some ways for the firsthand knowledge

Describe some ways in which the firsthand knowledge we have of some topic goes beyond what we are able to write down in a language. What accounts for our inability to express this knowledge?

  Compare & swap object, but also eliminating the head array

Simplify the non-blocking universal algorithm for consensus objects (Figure 14.28) by using the specific Compare & Swap object, but also eliminating the Head array.

  Economists find the prisoner''s dilemma

Economists find the Prisoner's Dilemma game interesting because in it, players who act in their own self-interest, don't end up better off--they end up worse off instead. Explain why it is both a good thing and bad thing that when a person acts in th..

  How many more motors should be tested

To determine the efficiency of a batch of production of electric motors, 10 motors are tested. The average efficiency of the sample is calculated to be 91.0%, and the standard deviation of the sample is 0.8 percentage point.

  Compute the variation of the rod temperature with time

A long conducting rod of diameter D and electrical resistance per unit length is initially in thermal equilibrium with the ambient air and its surroundings. This equilibrium condition is disturbed when an electrical current I is passed through the..

  Interchangeably because their meanings are equivalent

1. 1>Baud rate and data rate could be used interchangeably because their meanings are equivalent. True_ False_ And explain:

  Integrating diversity into workplace operations

When integrating diversity into workplace operations, why should you monitor and review workplace processes to guide implementation?

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