In this problem you will write code to simulate the markov


Questions -

Q1. Solve each part here; note these are four separate questions unrelated to each other.

(a) Show that the average of the Ri's determined over an entire cycle of a full period linear congruential generator (LCG) (mod m) is

U¯ = ½ - 1/2m.

(b) Use moment-generating functions (mgf) to show that any linear transformation Y = cX + d of any uniform r.v. X ∼ U(a, b) is itself uniform. (Note: To receive any credit you must first derive the mgf of Y , MY (t), from the mgf of X, MX(t), then explain how you know that MY (t) is the mgf of a uniform r.v. with appropriate parameters (in terms of a, b, c, and d). No credit will be given if you first state that Y is uniform (from its definition) and then determine its mgf.)

(c) Consider a set of independent and identically distributed (i.i.d.) r.v.'s U1, U2, U3, . . . s.t. U1 ∼ U(0, 1). For all k let Sk = i=1k Ui, and define Yk = Sk -⌊Sk⌋,

where ⌊x⌋ is the greatest integer less than or equal to x (notice this defines Yk as the fractional part of Sk). Show that Yk ∼ U(0, 1).

(d) A loaded six-sided die is rolled for which Pr{i appears} = ci for some c ∈ R (for i = 1, 2, . . . , 6). If i appears then a fair coin is flipped i times. Given that at least one H has appeared, what is the probability that a "2" was rolled?

Q2. In this problem you will write code to simulate the Markov chain from the up-down stock problem we have been discussing in lecture (i.e., your code will yield the stock being up or down each day for a set of N days). Note: You may use any programming language among R, Matlab, or VBA. (Note: You must email me your code as I will be running it myself to check its validity in solving this problem.)

(a) Let pup represent the probability the stock is up on Day 0. For now let pup = 0.5. Use random number generation (RNG) to determine whether or not the stock is actually up on Day 0.

(b) Recall that if the stock is up today then the stock will be up tomorrow with probability 0.8, if it is down today then it will be down tomorrow with probability 0.6. Use RNG to determine whether or not the stock is up on Day 1. Define a variable "StockUp" that keeps track of whether or not the stock is up (StockUp = 1 if up, StockUp = 0 if down) during the current day. Additionally, define a variable "NumUp" to keep track of how many days (starting with Day 1) the stock is up over the length of your model.

(c) Now, define a loop and use RNG to determine if the stock is up on each of Day 2, Day 3, . . . , Day N, for N ∈ {5, 10, 25, 100, 1000, 10000, 100000}, being sure to update "StockUp" and "NumUp" appropriately. Notice that the fraction of days (over your entire model) for which the stock was up is

pˆ ≡ NumUp/N.

Recall the steady-state probability for the stock being up was determined to be πup = 2/3. Comment on any patterns you see in the value of ˆp in terms of N, specifically in relation to πup.

(d) Finally, rerun your code for the same set of values of N, but now varying the value of Day 0 probability pup (pick several values between (and including) 0 and 1). Does the value of pup affect pˆ for all N? Does it have a more significant effect for particular N? And are there N for which varying pup appears to have no effect on pˆ? Is this as expected? Discuss.

Request for Solution File

Ask an Expert for Answer!!
Basic Statistics: In this problem you will write code to simulate the markov
Reference No:- TGS02688798

Expected delivery within 24 Hours