Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++, Putty, emacs Pleas and Thank you. Box-Muller Transformation Project The objective of this lab is to use a Monte Carlo algorithm to generate random

C++, Putty, emacs

image text in transcribed

Pleas and Thank you.

Box-Muller Transformation Project The objective of this lab is to use a Monte Carlo algorithm to generate random samples from a Gaussian distribution. A Gaussian distribution is characterized by the average value of a population, called the expectation value, and the standard deviation. The following algorithm is used to generate random samples from a Gaussian distribution. First, generate a random value in the interval 01) from the uniform distribution, U(0,1). A random value from this distribution can be easily generated using randO/static_cast (RAND_MAX). Next, transform the uniform random value generated to a random value from the standard normal distribution. The standard normal distribution is a Gaussian distribution with an expectation value of = 0, and a standard deviation of = l. This is done by randomly returning either 20 or Z1 of the Box-Muller transformation where - Zo = V -2 In 1 cos(2n14) and U1 and U2 are random samples from U(0,1) Lastly, transform the value of Z to a random value from a Gaussian distribution with user-specified values for and using the equation 1. (3 points) Write a function to generate randoves frm the uniform distribution in the interval (0,1), i.e., 0 sU 1. This function should take no formal parameters. 2. (3 points) Write a function that implements the Box-Muller transform to randomly return Zo or Z1. This function should take no formal parameters and should call the function from step 1 to get U and U2. 3. (3 points) Write a function to return a sample from a Gaussian distribution with a user-specified expectation value, , and standard deviation, . This function should take take two formal parameters ( ad ). Further it should call the function written in step 2 to get Z. 4. (3 points) Write a driver program that generates 1000 values randomly sampled from a Gaussian distribution with = 500 and = 50. Write a function that accumulates the sum of the generated values using a static variable, and which returns the moving average as the random values are generated. 5. (3 points) Write a function to compute the percent difference between the sample average and the expectation value. cout the final average and the percent difference from the expectation value. The percent differece should be calulated as computed average and is the expectation value. 15 points total K2-HI where is the

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

More Books

Students also viewed these Databases questions