1

I want to implement the following gaussian process in Matlab. So far i tried normpdf and normrnd but the results are not what i was expecting. B is an NxN matrix and the expected result for en is a Nx1 vector. Using both methods I get an NxN matrix.

Any suggestions?

gaussian process

1
  • Mh, this looks weird. If you use a matrix as sigma, you should be dealing with a multivariate distribution, and you should receive a matrix back. Commented Dec 14, 2017 at 22:02

2 Answers 2

1

I think this is what you are looking for:

% Number of samples for each variable:
k = 100;

% Your parameters:
mu = [0; 0]; % Vector of Means (0 in your case)
cov = [3 1; 1 3]; % Covariance Matrix (your B)

% Draw the samples...
s = mvnrnd(mu,cov,k);

If you want to perform the same calculation manually (by generating a sample of independent standard normal variables and then applying the appropriate transformation):

% Number of samples for each variable:
k = 100;

% Your parameters:
mu = [0 0]; % Vector of Means (0 in your case)
cov = [3 1; 1 3]; % Covariance Matrix (your B)

% Draw the samples...
s_ind = randn(k,size(cov,1));
s = repmat(mu,k,1) + (chol(cov) * ind_s);
Sign up to request clarification or add additional context in comments.

Comments

1

The documentation page for randn shows the following example for generating samples from a bivariate normal distribution:

mu = [1 2];
sigma = [1 0.5; 0.5 2];
R = chol(sigma);
z = repmat(mu,10,1) + randn(10,2)*R

mu is the mean vector which you should set to a zero vector of appropriate size. sigma is the covariance matrix, B^-1 in your example. The example above draws 10 samples, you can change this to however many you need. Also remember to change the dimension 2 to N in your application.

1 Comment

Thank you for your reply

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.