Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 2 0 pts ) One nice property for Gaussian distributions is that if we marginalize over any subset of dimensions of a multivariate Gaussian,

(20 pts) One nice property for Gaussian distributions is that if we marginalize over any subset
of dimensions of a multivariate Gaussian, the resulting distribution is also Gaussian. To marginalize a
multivariate random variable means to find the distribution of only the marginalized random variables and
eliminate from the distribution the other random variables. This is achieved by adding or integrating the
distribution function with respect to all other random variables, e.g. for a continuous multivariate random
variable (,) with PDF ,(,) we can marginalize on x by doing ()=,(,)
+\infty
\infty . This means
the distribution of a marginalized multivariate Gaussian distribution looks like the familiar bell shape
characteristic of a univariate Gaussian distribution.
a) Use the below code to generate the PDF for a bivariate Gaussian. Then, in a separate figure, plot the
PDF when you marginalize (integrate with respect to ), and overlay a plot of the PDF when you
marginalize (integrate with respect to ), both on the same plot using legends.
b) Using your knowledge of the Gaussian PDF, estimate the mean of each marginal distribution and display
these means on your plot.
Show your plot and code.
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import multivariate_normal
# Define mean (mu) and covariance matrix (sigma)
mu = np.array([0,3])
sigma = np.array([[5,-2],[-2,2]])
# Create a grid of x1 and x2 values
x1= np.arange(-10,10.1,0.1)
x2= np.arange(-10,10.1,0.1)
X1, X2= np.meshgrid(x1, x2)
# Create a multivariate normal distribution
mvn = multivariate_normal(mean=mu, cov=sigma)
# Calculate the PDF values for each point in the grid
pdf_values = mvn.pdf(np.column_stack((X1.ravel(), X2.ravel())))
# Reshape the PDF values to match the grid shape
F = pdf_values.reshape(X1.shape)
# Create a contour plot
plt.contour(x1, x2, F)
# Set plot attributes
plt.grid(True)
plt.axis('square')
plt.title('Your Name CMPE 677, Hwk 1, Problem 10', fontsize=12)
# Save the plot as a PNG file
plt.savefig('cmpe677_hwk1_10.png', format='png')
# Show the plot
plt.show()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions

Question

Find the radius and volume of the 10743Tc nucleus.

Answered: 1 week ago

Question

Tell me about yourself.

Answered: 1 week ago

Question

a sin(2x) x Let f(x)=2x+1 In(be)

Answered: 1 week ago

Question

Develop a program for effectively managing diversity. page 303

Answered: 1 week ago

Question

List the common methods used in selecting human resources. page 239

Answered: 1 week ago