131k views
2 votes
Use Matlab to create a pair of zero mean Gaussian random variables with the following covariance matrix.

Q ₓ = [1.0 0.5]
[0.5 1.0]
Simulate the data and make a scatter plot using using N=1000 data points for both x ₁ and x ₂.

User Nick Zhang
by
6.8k points

1 Answer

5 votes

Final answer:

To simulate zero mean Gaussian random variables with a specific covariance matrix using Matlab, define the covariance matrix, set the mean to zero, use the 'mvnrnd' function and then create a scatter plot.

Step-by-step explanation:

To create a pair of zero mean Gaussian random variables with a given covariance matrix in Matlab, you first need to specify the covariance matrix and the number of data points you want to generate.

The covariance matrix you've provided is Qₓ = [1.0 0.5; 0.5 1.0]. To generate random variables with this covariance, you can use Matlab's mvnrnd function, which generates multivariate normal random numbers.

Here's a step-by-step guide to do this:

  1. Define the covariance matrix: Qₓ = [1.0 0.5; 0.5 1.0].
  2. Set the mean vector to zero for both variables: mu = [0 0].
  3. Use the mvnrnd function to generate a matrix of random numbers: data = mvnrnd(mu, Qₓ, N), where N is 1000.
  4. Create a scatter plot of the generated data points: scatter(data(:,1), data(:,2)).

Here is the corresponding Matlab code:

N = 1000;
mu = [0 0];
Qx = [1.0 0.5; 0.5 1.0];
data = mvnrnd(mu, Qx, N);
scatter(data(:,1), data(:,2));
title('Scatter Plot of Gaussian Random Variables');
xlabel('x_1');
ylabel('x_2');

User Anuj Patel
by
7.6k points