Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Let X be a random variable with X~ N(, 02). The PDF of X is written explicitly as (2-) fx(x) = (1) (a) Let

Let X be a random variable with X~ N(, 02). The PDF of X is written explicitly as (2-) fx (I) = 1 20 (1) (a) Exercise 2: Gaussian Whitening In this exercise, we consider the following question: suppose that we are

Let X be a random variable with X~ N(, 02). The PDF of X is written explicitly as (2-) fx(x) = (1) (a) Let = 0 and o= 1 so that X ~ N(0,1). Plot fx (r) using matplotlib.pyplot.plot for the range T[-3,3]. Use matplotlib.pyplot.savefig to save your figure. (b) Let us investigate the use of histograms in data visualization. (i) Use numpy.random.normal to draw 1000 random samples from N(0, 1). (ii) Make two histogram plots using matplotlib.pyplot.hist, with the number of bins m set to 4 and 1000. 1 20 e 202 (iii) Use scipy.stats.norm.fit to estimate the mean and standard deviation of your data. Report the estimated values. (iv) Plot the fitted gaussian curve on top of the two histogram plots using scipy.stats.norm.pdf. (v) (Optional) Ask yourself the following questions: Are the two histograms representative of your data's distribution? How are they different in terms of data representation? (h) = (c) A practical way to estimate the optimal bin width is to make use of what is called the cross validation estimator of risk of the dataset. Denoting h= (max data value-min data value)/m as the bin width, with m = the number of bins (assuming you applied no rescaling to your raw data), we seek h* that minimizes the risk (h), expressed as follows: m 2 n+1 h(n 1) h(n 1) P, - j=1 (2) where {}1 is the empirical probability of a sample falling into each bin, and n is the total number of samples. (i) Plot (h) with respect to m the number of bins, for m= = 1, 2, ..., 200. (ii) Find the m* that minimizes (h), plot the histogram of your data with that m*. (iii) Plot the Gaussian curve fitted to your data on top of your histogram. 1 Exercise 2: Gaussian Whitening In this exercise, we consider the following question: suppose that we are given a random number generator that can only generate zero-mean unit variance Gaussians, i.e., X~ N(0, 1), how do we transform the distribution of X to an arbitrary Gaussian distribution? We will first derive a few equations, and then verify them with an empirical example, by drawing samples from the 2D Gaussian, applying the transform to the dataset, and checking if the transformed dataset really takes the form of the desired Gaussian. (a) Let X~ N(, E) be a 2D Gaussian. The PDF of X is given by 1 fx(x) = V(2)2|| where in this exercise we assume X X X = 7 x = [121] (i) Simplify the expression fx (x) for the particular choices of and here. Show your derivation. (ii) Using matplotlib.pyplot.contour, plot the contour of fx (x) for the range x [-1,5] x [0, 10]. transformation that can map X to an arbitrary exp {-} (x ) (x )}}, (b) Suppose X~ N(0,1). We would like to derive Gaussian. = Hy = " and = (3) (i) Let X ~ N(0, 1) be a d-dimensional random vector. Let A E Rdxd and be Rd. Let Y = AX +b be an affine transformation of X. Let py E[Y] be the mean vector and Ey Hy)] be the covariance matrix. Show that def def E[(Y-HY) (Y- Hy = b. and Xy = AAT. (ii) Show that Ey is symmetric positive semi-definite. (iii) Under what condition on A would Ey become a symmetric positive definite matrix? (iv) Consider a random variable Y~ N(y, Ey) such that (4) (5) and y = Determine A and b which could satisfy Equation (5). Hint: Consider eigen-decomposition of Ey. You may compute the eigen-decomposition numeri- cally. (c) Now let us verify our results from part (b) with an empirical example. (i) Use numpy.random.multivariate_normal to draw 5000 random samples from the 2D standard normal distribution, and make a scatter plot of the data point using matplotlib.pyplot.scatter. 2 (ii) Write a Python program using numpy.linalg.eig to obtain A given Ey in part (b)(iv). Apply the transformation to the data point, and make a scatter plot of the transformed data points to check whether the transformation is correct. (iii) (Optional) Do your results from parts (c) (i) and (ii) support your theoretical findings from part (b)?

Step by Step Solution

3.42 Rating (149 Votes )

There are 3 Steps involved in it

Step: 1

Exercise 1 a Plotting PDF of N0 1 Python import numpy as np import matplotlibpyplot as plt from scipystats import norm Parameters mu 0 sigma 1 x nplinspace3 3 1000 pdf normpdfx mu sigma Plotting pltpl... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistical Inference

Authors: George Casella, Roger L. Berger

2nd edition

0534243126, 978-0534243128

More Books

Students also viewed these Programming questions

Question

Which are the strongest parts?

Answered: 1 week ago

Question

Which character has an opposite script?

Answered: 1 week ago