Mth 4135 midterm assignment write code that will use the


Midterm Assignment -

Q1. a. Write code that will use the inverse transform to generate a random variable X which has probability density fX(x) = 4/x2, 2 ≤ x ≤ 4 (and 0 for other values of x).

b. Write code that will generate a point (x and y coordinates) uniformly from the region 2 ≤ x ≤ 4, 0 ≤ y ≤ 4/x2.

Q2. a. Write code that will generate a sample from the distribution Uniform (2, 4).

b. Then, use accept/reject to write code which (using this uniform distribution) generates samples from fX(x) = 4/x2, 2 ≤ x ≤ 4. (To be clear: we're doing the same distribution from question 1, but this time there should be no inverse transforms.)

Q3. a. Suppose that I want to generate a random variable Y that is distributed as Binomial (2, 0.4), using the discrete inverse transform. Fill in /***BLANK 1***/ and /***BLANK 2***/ so that this code runs as quickly as possible. Pay attention to the order of the entries.

double Y;

double P_i_vals[3] = {/***BLANK 1***/};

double X[3] = {/***BLANK 2***/};

double U = MTUniform (0);

for (int i = 0; i <= 2; i++) {

if (U <= P_i_vals[i]) {

Y = X[i];

break;

}

}

b. On average, how many times will the test U <= P i vals[i] have to run to generate the value of Y?

Q4. Suppose you wish to generate a random permutation of {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. Write pseudo-code explaining an efficient algorithm for this task.

Q5. I draw two independent samples from a normal distribution with mean known to be 0, but unknown variance (which we'll call v). The samples drawn have values 2 and 0. What is the Maximum Likelihood Estimator of v? Show work (there's a shortcut to the answer in this case, but that's not what I want).

Q6. a. Write code that simulates one path of Brownian motion from time t = 0 to t = 1. To be precise: the code should generate B0, B.01, B.02, . . . , B1, printing out each value.

b. Recall our stock price model based on Brownian motion, which we summarized with the equation St = S0eµt+σB_t. Suppose that ?t = 0.01, µ = 0.05, σ = 0.3. Write code that simulates a single price path, and then gives the payoff of a (European) call option on this stock with strike 105, which expires at time T = 1.

Note - Need code in python. Thank you.

Solution Preview :

Prepared by a verified Expert
Advanced Statistics: Mth 4135 midterm assignment write code that will use the
Reference No:- TGS02787564

Now Priced at $60 (50% Discount)

Recommended (92%)

Rated (4.4/5)