0

answers

0

watching

97

views

6 Nov 2019

#

you must use matlab or octave program. others are not allowed T.T. please use only above the two program to get solution.

Problem 3: The Inverse Transformation Method A general method for simulating a RV having a continuous distribution called the inverse transformation method is based on the following result (see also Section 10.2 of the textbook and Quiz 2) Proposition 2.1. The Inverse Transformation Method). L UN U(0,1). For any continuous et distribution function F, X F-1(U) has distribution function F. (F-1(ar) is defined to equal that value y for which F(y) r.) In order to simulate X n Exp(1), for example, generate an U U(0,1) and let X log(1 -U) (see Quiz 2(c)). In fact, X log(U) is also Exp(1), since 1 U (0,1). Since X Exp(A) if X Exp(1) (why?), it follows that log(U)A has an Exp(1) distribution. This can be easily illustrated in Octave xi -log Grand (100,1)); 100 random samples from Exp (1) x2 -log (rand (100, 1))/2; 100 random samples from Exp(2) x3 -log Grand (100, 1))*2; 100 random samples from Exp(0.5) [mean (x1) mean(x2) mean (x3)] check their mean values In addition, Y X Gamma(n, A) if X Xn are i.i.d. Exp(A). Therefore, if Un are i.i.d. U(0, 1), log (Ui) 1 log Ui Gamma(n, A) (1) i-1 i-1 (a) Write an Octave code to generate 100 random samples from Gamma(10, A) by using the inverse transformation method (1). Let A 0.5, 1, 2. Plot histograms for the Gamma random samples. Octave also has a built-in gamma RV generator gamrnd (google it for reference!). Generate 100 random samples of Gamma(10, A) using gamrnd, make histograms, and compare two results. (b) As a function of U U(0, 1), create a new RV W with CDF F(w) 1 e-ti (w 0). (This is Quiz 2 (b).) Write an Octave code to generate 100 random samples of W F using the inverse transformation method (c) Consider a method for generating Weibull(a,B) RVs that have the following CDF F(z) exp(-ar 0 z oo, a Note that W in (b) is in fact Weibull(1,2). Write an Octave function myweibrnd.m that will generate n random samples for given parameters a and B. It should have the following format function CRJ myweibrnd n, alpha, beta) this function receives sample size n and parameters alpha and beta as input arguments and return R Ca vector of n random samples) (put your code here) Using your myweibrnd function, generate 1000 simulated values when (i) (a, B) (1,2) and (ii) (a,B) (2,1), respectively. Plot histograms and estimate their mean and variance Show transcribed image text

you must use matlab or octave program. others are not allowed T.T. please use only above the two program to get solution.

Problem 3: The Inverse Transformation Method A general method for simulating a RV having a continuous distribution called the inverse transformation method is based on the following result (see also Section 10.2 of the textbook and Quiz 2) Proposition 2.1. The Inverse Transformation Method). L UN U(0,1). For any continuous et distribution function F, X F-1(U) has distribution function F. (F-1(ar) is defined to equal that value y for which F(y) r.) In order to simulate X n Exp(1), for example, generate an U U(0,1) and let X log(1 -U) (see Quiz 2(c)). In fact, X log(U) is also Exp(1), since 1 U (0,1). Since X Exp(A) if X Exp(1) (why?), it follows that log(U)A has an Exp(1) distribution. This can be easily illustrated in Octave xi -log Grand (100,1)); 100 random samples from Exp (1) x2 -log (rand (100, 1))/2; 100 random samples from Exp(2) x3 -log Grand (100, 1))*2; 100 random samples from Exp(0.5) [mean (x1) mean(x2) mean (x3)] check their mean values In addition, Y X Gamma(n, A) if X Xn are i.i.d. Exp(A). Therefore, if Un are i.i.d. U(0, 1), log (Ui) 1 log Ui Gamma(n, A) (1) i-1 i-1 (a) Write an Octave code to generate 100 random samples from Gamma(10, A) by using the inverse transformation method (1). Let A 0.5, 1, 2. Plot histograms for the Gamma random samples. Octave also has a built-in gamma RV generator gamrnd (google it for reference!). Generate 100 random samples of Gamma(10, A) using gamrnd, make histograms, and compare two results. (b) As a function of U U(0, 1), create a new RV W with CDF F(w) 1 e-ti (w 0). (This is Quiz 2 (b).) Write an Octave code to generate 100 random samples of W F using the inverse transformation method (c) Consider a method for generating Weibull(a,B) RVs that have the following CDF F(z) exp(-ar 0 z oo, a Note that W in (b) is in fact Weibull(1,2). Write an Octave function myweibrnd.m that will generate n random samples for given parameters a and B. It should have the following format function CRJ myweibrnd n, alpha, beta) this function receives sample size n and parameters alpha and beta as input arguments and return R Ca vector of n random samples) (put your code here) Using your myweibrnd function, generate 1000 simulated values when (i) (a, B) (1,2) and (ii) (a,B) (2,1), respectively. Plot histograms and estimate their mean and variance

Show transcribed image text