You are on page 1of 5

Alert when this question is answered

× ★★★★★ OPEN APP


4,500+ five-star reviews

  Textbook Solutions Expert Q&A Practice 

home / study / math / statistics and probability / statistics and probability questions and answers /...
Find solutions for your homework

Question: Question 5 (30 points, Matlab Simulations -


Simulation of conditional distribu- tion and ability ...
please write matlab
code

Show transcribed image text

Expert Answer

Anonymous
answered this

ANSWER:

computing EX For EX] we have to repeat the computation of EXA for many generated λ values and then
average EXA]. For this part, repeat the generation of λ for 100000 times, and then average EXs for these
100000 values. Question 5 (15 points, Matlab Simulations): In Matlab, we typically generated ran dom
mumbers cither uniformly via rand function, or nomally via randnfunction. Often, we need to generate
random numbers for a given distribution. For example, we need expo- nentially distributed or Gamma
distributed random variables. Luckily, we have developed a method that takes uniformly distributed
random variables into any other distributions. To get the idea, check the gure given in Fig. 1, The CDF of
any random variable is mono- tonically increasing and is always between 0 and 1. This is shown on the left
plot 1 On the right hand side, we have plotted the inverse function of the CDF. As you can see, the
horizontal axis is between 0 and 1 and the inverse of CDF function axis into the vertical axis. Hence, if we
uniformly pick a value between 0 and 1 and then evaluate for the inverse function of CDF of X, then we
get the samples that are distributed according the distribution of x In this simulation, we will verify the
result of Q4 Part a. For exponential rando variable, Fx(x) 1- and the inverse function is maps the horizontal
Figure 1: Method to generate samples of X from uniform distribution via Fx 0 (a) (5 Pts.) Per Q4 Part a,
unifornly pick a λ value between 1 and 2, Fix this value. Now for 10000 values of uniformly distributed
uvalues, obtain X values per Equation() (b) (5 Pts.) Plot the normalized PDF histogram of generated X values
and then compare it with the theoretical exponential PDF for a generated λ value. Do plots agree? (e) (5
Pts.) Compute E via iterated expectation. Verify that it agrees with Q4 Part a. Hint: If we determine the
average of the data generated, then we woukd indeed be

To generate a uniform random number between [a,b] we will use a+(b-a)*rand()


Matlab code is below

Get this plot

The theoretical and empirical plots agree to a great extent.

c) We have the following hierarchy

Using the iterative expectation we can write the expectation of X as

The matlab code is below


Get this output

This is close to the theoretical expectation of X, which is 0.6931

0 Comments

Was this answer helpful? 1

Up next for you in Statistics and Probability

l Uniiorm Itandom If each of a set of raw


Variable A uniform scores is transformed into
random variable X, that is a Z-score, the new
distributed uniformly in … distribution will have a s…
See more quest
for subjects you s
Solution Image

See answer See answer

Questions viewed by other students

computing EX For EX] we have to repeat the computation of EXA for many generated λ values and then
average EXA]. For this part, repeat the generation of λ for 100000 times, and then average EXs for
these 100000 values. Question 5 (15 points, Matlab Simulations): In Matlab, we typically generated ran
dom mumbers cither uniformly via rand function, or nomally via randnfunction. Often...
See answer 100% (1 rating)


l Uniiorm Itandom Variable A uniform random variable X, that is distributed uniformly in the interval a, b,
has the following PDF Ea 0, otherwise fx(1)- - and Var(X)- lt is easy to show that the mean and
variance of X are E respectively The function rand in Matlab can be used to generate realizations of the
standard uniform random variable, with α-0 and 1·The following codes...
See answer 100% (1 rating)

Show more 
COMPANY

LEGAL & POLICIES

CHEGG PRODUCTS AND SERVICES

CHEGG NETWORK

CUSTOMER SERVICE

© 2003-2021 Chegg Inc. All rights reserved.

You might also like