Generating multivariate random variables

Assignment Help Electrical Engineering
Reference no: EM13203381

Part 1 - Generating Random Variables

Most software libraries include a uniform random number generator that generates equally probable numbers between 0 and 1. A uniform RV can be used to generate random variables with other distributions. For example suppose that we want to generate a new random variable X with pdf fX. Specifically, we want to generate a Gaussian random variable with the following pdf:

501_Generating Random Variables.png

where σx2  is the variance of the distribution and μx is the mean.  

We also know that the probability

2172_Generating Random Variables1.png

is a number between [0,1], that we will denote as "A". If we want to find out what value of x0 will make the integral in (2) equal to A, an inverse mapping for the integral in (2) needs to be evaluated. Unfortunately it is hard to express the integral in (2) in terms of simple functions.

In EE-131A & B, we also learned about the relationship between Rayleigh and Gaussian distributions. The Rayleigh CDF can be expressed as

644_Generating Random Variables2.png

where r is related to a pair of Gaussian random variables by the transformation

2341_Generating Random Variables3.png

and σ2 is the variance of both the Gaussian RVs.

The function in (3) is a lot simpler to invert than the integral in (2):

1890_Generating Random Variables4.png

We can also generate a second uniformly distributed random variable B~U[0,1]  and define θ = 2ΠB.

Your  task: Write the proper code such that:

  • Complete the missing portion of the a function GenerateGauss(mu,sigma2) that will generate a two Gaussian random variables from a single uniform random variable u.
    • If the function is given no arguments, then the default settings are mu=0, sigma2=1
    • If only one argument is given then we assume that value is the variance, and assume mu=0
  • You will see that the function you wrote is much slower than the internal Matlab function. To make the code a bit more efficient, generate a new function GenerateGaussVector(mu,sigma2,N).
    • You should expect to be much faster than the original one you wrote, however you probably won't be able to beat Matlab's internal function randn.(Matlab's internal function is probably around 4 times faster than your version of GenerateGaussVector )
    • For this section your code has 3 inputs. If less than 3 inputs are given by the user then you should do the following. If GenerateGaussVector(arg1, arg2, arg3).

- 0 args: Generate TWO random variables with distribution Gaussian(0,1)  

- 1 arg: Generate TWO random variables with distribution Gaussian(arg1,1)

- 2 args: Generate TWO random variables with distribution Gaussian(arg1,arg2) 

- 3 args: Generate a vector (of even length) with random variables of dimension N=arg3 with distribution Gaussian(arg1,arg2). For example:

  • GenerateGaussVector(a, b, 4)-> Generates 4 RVs with dist. Gaussian(a,b)
  • GenerateGaussVector(a, b, 5)-> Generates 4 RVs with dist. Gaussian(a,b)
  • GenerateGaussVector(a, b, 6)-> Generates 6 RVs with dist. Gaussian(a,b)
    • For this section, you do not need to handle the special case where the input is GenerateGaussVector(a, b, 1)
  • GenerateGaussVector(arg1, arg2, 1)à Generates an empty vector
  • Again, for this section you do not need to worry about the special case of N=1 for the problems on this section

When you open the provided Matlab files, you will see sections labeled like this:

You are only supposed to modify the portion of the code marked.

The way it's written, the "skeleton" code provided will run. However, the outputs will likely be all zeros.

When a vector of zeros is defined between the lines of code that you are supposed to edit, be smart to realize that your solution should have the same dimensions as the vector you are replacing

Once you are done writing your functions, your output should look somewhat like this (the numbers may vary a bit ...)

Matlab Function: Mean=9.9984  Var=3.9750
EE131B Function: Mean=10.0055 Var=4.0024

Matlab Internal Function is 87.03 times faster than ours
Matlab Internal Function is 1.76 times faster than our vector function
The vector function is 49.58 times faster than our 1-D function

Part 2 - Generating Multivariate Random Variables

For our next application, we want to generate a multivariate Gaussian random variable.  Your function will now take as inputs

  • A vector of mean values: mx
  • A covariance matrix: Cx

And will use your function GenerateGauss to compute the two dimensional pdf.

In part (c) you will do a 3-D plot of the multidimensional Gaussian pdf, according to:

2003_Generating Random Variables5.png

Complete the code in the Matlab script "ProjectPart_02.m"  to compute the two dimensional pdf.

Use the "mesh" function in Matlab to display your result

Your output should look like this

My Vector of Means values is mx=[2.0, -2.0]
My autocorrelation matrix is Cx=
[     1.00 0.50 ]
[     0.50 1.00 ]

The Dimensions of my vector of Gaussian RVs is [2 x 1]
The mean and variance of my 2-D Gaussian Vector are:

      Mean=[2.01 , -1.99] 
      Var =[1.01 , 1.01]

1334_Generating Multivariate Random Variables.png

241_Generating Multivariate Random Variables1.png

Hints:

In Matlab, the function sqrtm() can be used to take the square root of the autocorrelation matrix. You may choose to use this function when you write the code for multidimensional_gp to properly scale the output vector

Cx =
    1.0000    0.5000
    0.5000    1.0000

>>  X = sqrtm(Cx)

X =
    0.9659    0.2588
    0.2588    0.9659

Part 3 - Power Spectrum of a Random Process

A random process X(t) can be characterized in the frequency domain by its power spectral density SXX(f), which is the Fourier transform of the autocorrelation function RXX(τ)

817_Generating Multivariate Random Variables2.png

Your Task:

Complete the code in "ProjectPart_03.m". This involves:

  • Generating a discrete time sequence of IID uniformly and Gaussian distributed random numbers
  • Computing the estimate of the autocorrelation of the sequence {Xn} by doing an ensemble average

410_Generating Multivariate Random Variables3.png

Note: In the equation above you can  the Matlab functions conv or xcorr to compute the integral or you can write your own function to perform the integration. In order to obtain the right result, make sure to properly normalize by the vector t.

  • Computing the PSD of the sequence {Xn} using the periodogram method and a single realization of the random sequence {Xn}

2089_Generating Multivariate Random Variables4.png

  • Comparing the performance of an ensemble average vs. a single realization average

Tasks:

a) Run the Code using the variable

MyDistribution =1; % Uniform Random Variable

Your output should look like this

Project - Part 3
Uniform RV
Ensemble    PSD: Mean=0.044
Periodogram PSD: Mean=0.039

And the following 4 figures should be generated

946_Generating Multivariate Random Variables5.png

244_Generating Multivariate Random Variables6.png

b) Run the Code using the variable 

MyDistribution =2;    % Gaussian Random Variable

 Your output should look like this

Project - Part 3

Gaussian RV

Ensemble    PSD: Mean=0.672

Periodogram PSD: Mean=0.563

And the following 4 figures should be generated

1029_Generating Multivariate Random Variables7.png


Download:- Project.rar

Reference no: EM13203381

Questions Cloud

How many centimeters from the central axis of the artery : where k is a constant and R is the radius of the artery. How many centimeters from the central axis of the artery is velocity of blood maximized?
Experimental participants perform a dull task : A research study had experimental participants perform a dull task but paid them to lie by telling a prospective participant that the task had been enjoyable. Results showed that the participants who were paid ___ came to believe that the task had be..
By what percent is the enrollment increasing each year : By what percent is the enrollment increasing each year?
Find which coin is the counterfeit coin : Determine which coin is the counterfeit coin in as few weightings as possible. Does your method also allow you to state whether the counterfeit coin is heavy or light?
Generating multivariate random variables : Generate a new random variable X with pdf fX. Specifically, we want to generate a Gaussian random variable and relationship between Rayleigh and Gaussian distributions.
Find a real-world application of a linear equation : Find a real-world application of a linear equation and discuss the meaning of the equation. Then explain how the values of the slope affect the overall meaning of the equation.
Find a linear equation that models the number of gallon : A large koi pond is filled with a garden hose at a rate of 10 gallons per minute. After 5 minutes the pond has 475 gallons of water. Find a linear equation that models the number of gallons y of water in the pond after t minutes.
Alignment between standards-curriculum and instruction : What are the challenges of improving alignment between standards, curriculum, and instruction?
Find a rectangular garden dimensions : A gravel path of uniform width is to be built around the garden. How wide can the path be if there is enough gravel for 186 square feet?

Reviews

Write a Review

Electrical Engineering Questions & Answers

  Future generation telecommunication technology

Write a report on Future Generation Telecommunication Technology.

  Explain the two possible frequencies

What are the two possible frequencies to which the local oscillator could be set? What bandwidth should the 10.7 MHz IF amplifier have?

  Compute the probability that the system will fail

Calculate the probability that the system will fail in 3,000 hours. Supposing no failure of any component occurs in 5,000 hours of operation. What would be your revised estimate of failure rates of the components in your system?

  Control systems- pid controller

Control Systems- PID Controller, Which one of the following statements regarding the operation of a PID controller is definately false?

  Methods used to eliminate noise from a spatio-temporal

Methods used to eliminate noise from a spatio-temporal signal, Name and describe, in detail, 2 methods used to eliminate noise from a (spatio-temporal) signal. This question requires a clear, detailed explanation of the methods. Mathematical equation..

  Define transfer function - key informaiton

Transfer function : key informaiton, A linear time-invariant discrete-time system is excited by the input x[n] = d[n] + 2u[n-1] (d represents δ(delta)). The resulting output response with zero initial conditions is y[n] = ((0.5)^n * u[n]). De..

  Step-down transformer

Step-down transformer

  Synchronization primitive in multiprocessor systems

Describe why interrupts are not appropriate for implementing synchronization primitive in multiprocessor systems.

  Define the outputs of two nand

Can you confirm-The outputs of two"NAND" gates are connected to the inputs of an "EXCLUSIVE OR" gate.Each of the "NAND" gates has one input at logic high level and the other input

  Hhow many voice channels are carried by a transmission

How many voice channels are carried by a E1 transmission given 8 kHz sampling and 8 bit words? Why is an end of frame marker always required in a digital telephony system?

  Explain watts in cassette players

Watts in Cassette Players, A walker's cassette tape player uses 4 AA batteries in series to provide 6V to the player circuit. The four alkaline battery cells store a total of 200 watts-second of energy.

  Explain next generation transmission system

You are required to determine that this next generation transmission system will require a spectral efficiency of 5 bits/sec per Hertz.

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