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

  Calculate the stress intensity factor

Use the three-parameter zone finite element method or the boundary collocation method to calculate the stress intensity factor K, at the crack tip for the plate

  Build a simulation using newtons laws of motion

Build a new and different simulation of your own using Newtons laws of motion and Show the code and describe how it works

  Write the specification of load mover

Write the specification of LOAD MOVER detailed of the whole design and precise for automatic control section and divide the design into various modules and Is the kernel required if yes which one?

  Design the automatic control section using statecharts

Aim of this project is to design an embedded system which can move loads from one place to another. The system can be operated manually, automatically and wirelessly.

  Need an expert who can model a drill in simulink

Need an expert who can model a drill in Simulink. Working model of a drill needing for an improvment to behave more realistically as a drill to drill through plastic block.

  Project is on load frequency control using fpid

Project is on load frequency control using FPID tuned using GA and PSO algorithm and the system is a two area system.

  Number of packets received with time

Let x be the number of packets received with time -

  Build a matlab based graphical user interface

Build a Matlab based graphical user interface (GUI) that operates in conjunction with a base Matlab/ Simulink simulation program. Any base simulation is considered acceptable.

  Build a matlab based graphical user interface

Build a Matlab based graphical user interface (GUI) that operates in conjunction with a base Matlab/ Simulink simulation program. Any base simulation is considered acceptable.

  Simulate the standardised sum of independent

Simulate the standardised sum of independent and identically distributed variates - Fit a linear regression model as in Q5, and plot your estimates for β0 and β1 as N increases, together with a line indicating their true values. Supply your code.

  Plot the original periodic square wave

Plot the original periodic square wave on the same graph. Comment on the difference between the original periodic square wave and its truncated Fourier series presentation.

  Use matlab to plot the function

Plot the original periodic square wave on the same graph. Comment on the difference between the original periodic square wave and its truncated Fourier series presentation.

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