What are the analytical results for the mean and variance

Assignment Help Simulation in MATLAB
Reference no: EM132275557

MATLAB Assignment -

This MATLAB assignment is designed to reinforce your learning of the material. You should conduct the assigned matlab-based simulations, and submit a typed report in PDF that includes your observations, MATLAB codes, and generated figures. Solutions and answers to all questions, along with the figures, should be put together and organized into a concise report. The MATLAB codes are to be included at the end of the report in the Appendices section, with clear numbering.

Set 1: Generating Random Variables of Certain Distributions

1. Let X be a random variable obeying Bernoulli distribution. In a general form, it takes on two possible values a and b with probabilities p and 1 - p respectively, with 0 ≤ p ≤ 1, as follows (w.p. stands for with probability):

2064_figure.png

(a) Let a = 1, b = 0, and p = 0.6. Use MATLAB to generate a sequence of N = 20 independent realizations of X. Write down these N numbers.

(b) Plot the histogram of these N numbers? What do you observe?

(c) Write a MATLAB function "function X=my-bernoulli(p, N, a, b)" that yields a sequence of N outcomes of the above Bernoulli random variable. You may use this function to conveniently simulate Bernoulli random variables in the future.

Hint: Suppose that Y is uniformly distributed between [0, 1], which can be generated using "rand". Let

1626_figure1.png

What is the probability PZ(Z = 1) =? What is the probability PZ(Z = 0) =?

Can you extend this idea to generate a Bernoulli distribution with any two possible values a and b, and any parameter p ∈ [0, 1]? The above RV Z is a special case of the RV X with a = 1, b = 0, p = 0.6.

Can you extend this idea to generate the outcomes of a discrete random variable with a finite set of values?

Set 2: Computing mean and variance via simulations

Let {xn}n=1N be N samples/realizations of a random variable X that obeys certain distribution. The sample mean X- and sample variance s2X are given by

X- = (X)N = 1/N n=1N xn;

s2X = 1/(N-1) n=1N(xn - X-)2.

1. Let X be a random variable obeying Bernoulli distribution. It takes on two possible values a and b with probabilities p and 1 - p respectively, as follows (w.p. stands for with probability):

2432_figure2.png

Let a = 1, b = 0, and p = 0.6.

(a) What are the analytical results for the mean mX and variance σ2X of X?

(b) Use MATLAB to generate a sequence of N = 20 independent realizations of X. Compute the sample mean X-and variance s2X using the formulae above. Compute the sample mean and variance using the MATLAB functions "mean" and "var". Do you get the same results?

(c) Repeat (b) for N = 100 and N = 1000. Do the sample mean and variance change? Are they closer to the analytical results? Document your observations concisely.

2. Let X be a uniform discrete random variable that takes on values {1, 2, . . . , K} with equal probability, that is, pX(X = k) = 1/K for any integer k ∈ {1, 2, . . . , K}. For example, a fair 6-sided dice corresponds to K = 6.

(a) What are the analytical results for the mean and variance of X?

(b) Use MATLAB to generate a sequence of N = 20 independent realizations xn of X. Compute the sample mean  X- and variance s2X.

(c) Repeat (b) for N = 100 and N = 1000. Do the mean and variance change? Are they closer to the analytical results? Document your observations concisely.

(d) Another random variable Y is a uniformly distributed discrete random variable that takes on values {100, 101, 102, 103, 104, 105} with equal probability. Generate a set of N = 100 samples of Y, and compute its expected value mY and its sample mean Y-.

Set 3: Generating RVs of certain distributions as an inverse problem

The inverse problem:

Suppose that we would like to generate samples xi, i = 1, 2, . . . , following a desired distribution FX(x). This CDF FX(x) is a general function that is invertible, but not included in any MATLAB library. It can be proven that, if U is a uniformly distributed RV obeying U[0; 1] and X = g(U) = F-1X(U) (that is, U = FX(X)), then X is a RV with its CDF given by FX(x). Accordingly, you can start with generating a set of samples ui, ∀i, that are uniformly distributed between [0, 1], and then compute xi = g(ui) where the function g(·) is set to be g(u) = F-1X (u). The resulting xi, ∀i, obeys the CDF FX(x).

For a function of one random variable, solution to the inverse problem can be quite useful in system design, and in generating random numbers with arbitrary distributions for Monte Carlo simulations. This assignment provides such exercise.

1. The inverse problem above can be used to generate RVs of desired probabilistic distributions. We wish to generate a random number (RN) sequence xi, i = 1, . . . , N, with Rayleigh distribution. That is, {xi}i are random realizations of a RV X that obeys Rayleigh distribution. In this case, Rayleigh CDF : FX(x) = 1 - e-x^2/(2σ^2); inverse function : g(u) = F(-1)X (u) = √(-2σ2ln(1-u)).

When U is uniformly distributed in [0, 1], (1 - U) is uniform in [0, 1] as well. According to the inverse problem above, if we start with a RN sequence {ui}i=1N generated from a uniform distribution in [0, 1], then xi = √(-2 σ2lnui), i = 1, . . . , N, is a RN sequence with Rayleigh distribution.

(a) Find the mean and variance of the Rayleigh distributed X by analysis.

(b) Let σ2 = 1. Generate a RN sequence of length N = 1000 with Rayleigh distribution. Show the pdf by plotting the histogram. Compute the sample mean X- = 1/N i=1N xi and sample variance s2X = 1/(N-1) i=1N(xi - X-)2.

(c) Repeat (b) for σ2 = 0.5, 5, 10 respectively.

(d) Rayleigh distributed samples can also be generated from functions of Gaussian samples. Specifically, R is Rayleigh distributed with parameter σ2 if R = √(X2R + X2I) , where XR and XI are independent Gaussian RVs with the same distribution N(0, σ2). That is, for a complex variable X~ = XR + jXI, its amplitude R is Rayleigh distributed. Hence, you may use Gaussian samples XR and XI to generate Rayleigh distributed RV R. Repeat (b) using this alternative approach.

(e) Briefly explain your observations.

2. We wish to generate a RN sequence yi, i = 1, . . . , N, with exponential distribution, that is,

FY(y) = 1 - e-y/λ.

(a) Find the mean and variance of the exponential distributed Y by analysis.

(b) Generate a RN sequence of length N = 1000 with exponential distribution, for λ = 1. Show the pdf by plotting the histogram. Compute the sample mean and sample variance.

(c) Repeat (b) for λ = 0.5, 5 respectively.

(d) Briefly explain your observations.

Set 4: Law of Large Numbers

1. Let Xi, i = 1, . . . , N, be a sequence of independent identically distributed (i.i.d.) RVs, each following Rayleigh distribution with σ = 1. Consider a new RV given by the arithmetic mean

X = 1/N i=1NXi.

(a) Suppose that {Xi}i=1N are i.i.d. RVs with Rayleigh distribution (σ = 1) and N = 100. Generate L = 1000 realizations of X and show the pdf of X by plotting its histogram. Based on the histogram, do you think the pdf of X can be well approximated by a Gaussian pdf?

(b) Suppose that {Xi}i=1N are i.i.d. RVs with Rayleigh distribution (σ = 1) and N = 10000. Generate L = 1000 realizations of X and show the pdf of X by plotting its histogram. Do you think the pdf of X can be well approximated by a Gaussian pdf?

(c) Suppose that {Yi}i=1N are i.i.d. RVs with exponential distribution (λ = 1) and N = 100. Generate L = 1000 realizations of Y = 1/N i=1NYi and show the pdf of Y by plotting its histogram. Do you think the pdf of X can be well approximated by a Gaussian pdf?

(d) Suppose that {Yi}i=1N are i.i.d. RVs with exponential distribution (λ = 1) and N = 10000. Generate L = 1000 realizations of Y = 1/N i=1N Yi and show the pdf of Y by plotting its histogram. Do you think the pdf of X can be well approximated by a Gaussian pdf?

(e) Let

Z = (X1 + · · · + XN)/(Y1 + · · · + YN)

where {Xi} are i.i.d. Rayleigh distributed RVs and {Yi} are i.i.d. exponentially distributed RVs. N = 100. Generate L = 1000 random realizations of Z and compute the sample mean.

(f) Repeat (e) for N = 10000.

(g) Document your observations concisely.

Attachment:- Assignment File.rar

Reference no: EM132275557

Questions Cloud

Discussion about the business intelligence and big data : Choose a topic in which you are interested and in which you have prior knowledge. Research best company practices for the particular topic.
Example of ethnocentrism and cultural relativism : Can you provide an original example of ethnocentrism and cultural relativism and give your opinion about them?
Businesses require some standard style of documentation : Most schools and businesses require some standard style of documentation for written reports. Why might that be?
Saxonville sausage company case study : You need to develop and submit the answers to the following questions related to the 'Saxonville Sausage Company' Case Study.
What are the analytical results for the mean and variance : ECE528 MATLAB Assignment - Let X be a random variable obeying Bernoulli distribution. What are the analytical results for the mean and variance
What would you do to encourage more members : If you were the manager at CORE, what would you do to encourage more members to do most of their banking transactions electronically?
Describe gilgamesh : Describe Gilgamesh. What are his glories? What are his faults? What transforms Gilgamesh and Enkidu into friends rather than adversaries?
Groups requires cooperating and collaborating : Working together in groups requires cooperating and collaborating with others. It also requires motivation.
Successful change initiative from your own experiences : Describe a successful change initiative from your own experiences and why it worked well.

Reviews

len2275557

4/5/2019 12:27:23 AM

Instructions: Self-learn Section 5.2, 5.4 and 5.5 on the Central Limit Theorem and the Law of Large Numbers. This MATLAB assignment is designed to reinforce your learning of the material. You should conduct the assigned matlab-based simulations, and submit a typed report in PDF that includes your observations, MATLAB codes, and generated figures. Solutions and answers to all questions, along with the figures, should be put together and organized into a concise report. The MATLAB codes are to be included at the end of the report in the Appendices section, with clear numbering. This is also a chance for you to practice on writing a technical report. The report should be orderly and concise, directly addressing the questions posed in this assignment. Useful MATLAB commands: lookfor, help, rand, randn, unidrnd, binornd, poissrnd, nchoosek, mean, var, cov, function, hist, plot. There are other random variable generators in MATLAB, such as “binornd" and “poissrnd" for generating Binomial and Poisson random variables respectively.

Write a Review

Simulation in MATLAB Questions & Answers

  Create a vector with options variable

NSE 115 Homework - Functions and Control Flows. Create a vector with Options variable, i.e., Activity, NumAtoms, Both, and create a for loop that calls for your function such that it returns each of the following plots: Plot of number of atoms over..

  Draw the bode plots using matlab

Draw the Bode plots using MATLAB. Plot them one below the other on the same page. (Use subplot command). Label the axes, include title and grid.

  Negative feedback system with time delay

What T is required? Use Matlab to make a Bode plot for this value of T and draw the signal flow graph to represent the equations of the circuit. Use Mason's Rule to find the transfer function H(s).

  Derive the equations for the system in discrete time

Write (1) in state space formulation, as a continuous time linear time invariant system. Derive the equations for the system in discrete time

  What is simulated annealing

IN3044 - Artificial Intelligence Coursework - What is simulated annealing? How does it help search overcome the problem of local optima

  Effect on the ber of changing the way

Using M-PSK and QAM modulations with M>2, investigate the effect on the BER of changing the way in which the various bit combinations are mapped to the constellation points. Both binary and Gray mapping are available in the modulation dialogue box..

  Evaluate the inner product of the hilbert-transform pair

Find the Hilbert-transform pair, find the average power of the Hilbert-transform pair and evaluate the inner product of the Hilbert-transform pair.

  Build a simulation model to model given process

uild a simulation model in SIMUL8 to model this process. Find the average total time each type of customer spends in the system, as well as the number of balks. Also, find the maximum length of each queue, and both server utilisations.

  Compute the mean and standard deviation

EE 440 Assignment. Compute the mean and standard deviation. Plot the autocorrelation function of the x-gyro signal in Figure 3 for t = 0 to 1sec

  Select a modeling and prediction problem

Select a modeling and prediction problem. Work with actual data. Separate part of the data for training and others for testing. Train neural networks

  Verification of network theorems by simulation

Verification of Network Theorems by simulation, Lab Exercise: This will be simulation lab using MultiSim to understand the different network theorems

  To analyse given engineering component and critically review

To analyse given engineering component and critically review current surface engineering solutions applied to it.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd