Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.

Get a Professional Answer

Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.

100% Satisfaction Guarantee

Rate the answer you receive.

Ask Raj Your Own Question

Raj, Engineer

Category: Homework

Satisfied Customers: 1282

Experience: 4 + Experiance in IT Industry

16752232

Type Your Homework Question Here...

Raj is online now

2) Monte Carlo IntegrationWrite a C++ program to compute

This answer was rated:

★★★★★

2) Monte Carlo Integration Write a C++ program to compute the area of a circle of radius ‘r’ using a numerical method called “Monte Carlo Integration”. Imagine that the black square is a dartboard and that you are tossing darts at it randomly. With enough darts, the ratio of darts in the circle (Nc) to total darts thrown (Nt) is approximately equal the ratio between the area of the circle (circle_area = π(r)2) and the area of the square (square_area = (2r)2 ) which is easy to compute. We can simplify the math by only considering the first quadrant, calculating the ratio of the number of darts landed on the first quadrant over the number of darts landed on the top right square’s area. Study the following link to learn how to assign a random number to a variable http://www.cplusplus.com/reference/cstdlib/rand/. Define variables to store the x and y coordinates of a particular dart throw. In other words a random number between [0, r] gets assigned to the variables x and y, each (simulating one dart throw). Now, place your x and y declarations in a loop to simulate N dart throws. Note that all of these darts land on the top right square. Use the Euclidean distance formula, 𝑑=√𝑥2+𝑦2 to check if a dart is landed inside the first quadrant. Maintain account of the number of darts that end up in the first quadrant of the unit circle. Now use your loop to calculate the area of the circle by computing the ratio between Nt and Nc. Run your code for an arbitrary value of ‘r’ and compute the area of the circle based on the given values of Nt and fill out the following table. NT Area of a Circle 100 10,000 1,000,000 5,000,000 How accurate is your Monte Carlo Integration? Write a short paragraph and explain your observation.

- imagine you have a coordinate system with x=0..1 and y=0..1 (square) - r=1 (radius) - we consider a first quadrant of the coordinate system (see figure in your task) - the table shows different N (N throws of darts) - you need a loop with n-runs - each run calculates two random numbers x,y in the intervall 0..r (in our case 0..1,because r = 1) - then you have to check, if the point P(x,y) is located in the area of the circle - if yes -> increase a variable ("hit"-variable) - x^2 + y^2 < 1 -> point is located in the area of the circle with radius 1 - the area of the circle = a(N) = 4 * (hit-variable/N) - with radius of 1 you have probabilistic algorithm for the determination of pi - all details are without guarantee

Hope that helps, i will be on the computer all day so if you have any questions, just fire me a message. Thanks

Hello Raj, one last thing, when i go to test the code and enter in the values for N above, , 10000,(NNN) NNN-NNNN(NNN) NNN-NNNN it doesn't even calculate it only calculates for 100.

Based on Output the more the value of N (i.e. Number of Samples Collected) the better is the result. So it seems effective for our code except for the part for 100 Samples which can predict in the worst case Area of Circle as 4 as well which is way to larger than the guess.

So Its effective as the number of samples(N) Increases.

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.

JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.

Web sites like justanswer.com/legal ...leave nothing to chance.

Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.

Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.

I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C.Freshfield, Liverpool, UK

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. RobinElkton, Maryland

He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here.DianeDallas, TX

Meet The Experts:

LogicPro

Engineer

Satisfied Customers:

4925

Expert in Java C++ C C# VB Javascript Design SQL HTML