Part 1 - generating random variablesmost software libraries

Assignment Help Electrical Engineering
Reference no: EM13381210

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: EM13381210

Questions Cloud

Project task analyze the market over the week what was : project task analyze the market over the week. what was driving the market? what do you think caused the changes in the
Preparing an analysis of the marketcreate your portfolio : preparing an analysis of the marketcreate your portfolio. first set out your investment objectives and decide how
Select three problems that brick-and-mortar organizations : select three problems that brick-and-mortar organizations face as they transition toward becoming virtual
Tax return 1 corporate returnbackgroundjane collier james : tax return 1 corporate returnbackgroundjane collier james taye and steve allwine each own one-third of the common stock
Part 1 - generating random variablesmost software libraries : part 1 - generating random variablesmost software libraries include a uniform random number generator that generates
Part - aassignment problems 1 the constant-growth-rate : part - aassignment problems 1 the constant-growth-rate discounted dividend model as described equation 9.5 on page 247
Problem 1assume that mms theory holds with taxes there is : problem 1assume that mms theory holds with taxes. there is no growth and the 40 of debt is expected to be permanent.
Question what is internal timeamachine run time bautomatic : question what is internal time?amachine run time bautomatic time cthe time when a machine is not running dall of the
Baker has been assigned to research the literature for a : baker has been assigned to research the literature for a possible solution to a major operational problem at his

Reviews

Write a Review

Electrical Engineering Questions & Answers

  Lithium ion battery technology

The paper includes Lithium ion battery technology with its advantages and disadvantages. The paper discusses about the Lithium air battery in which detailed reactions of Lithium with air including nonaqueous as well as aqueous are given.

  Power transformers and tariffs

Construction of different types of power transformer, significant energy savings

  Paper on orthogonal frequency-division multiplexing

This document is shown a paper on Orthogonal frequency-division multiplexing with advantages, disadvantages and uses.

  Function of the hmi in a scada system

This assignment contains electronics engineering questions like State the commonly found components of a SCADA (Supervisory control and data acquisition) system. and decribe the function of the HMI in a SCADA system.

  Resultant waveform of the odd harmonic series

Prepare an Excel graph showing the individual components and summated resultant waveform of the odd harmonic series resulting in an approximate square wave.

  Explain scada system

Explain the function of the HMI in a SCADA system.

  Design a 2-digit 24 second shot-clock

Design a 2-digit 24 second "shot-clock" countdown timer with pushbutton controller.

  Model a discrete-time system

To understand di erent signal models To be able to model a discrete-time system and design simple signal processing algorithms.

  Draw a relay construction diagram

Draw a relay construction diagram and briefly explain the operation of a relay.

  Frequency division multiplexing

Write a short technical report on Frequency Division Multiplexing

  Impact of electron energy

Briefly discuss the impact of electron energy, electron current and target on the Bremsstrahlung generated.

  Traffic light controller

The schematic of the traffic light controller

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