views:

52

answers:

2

Can you please tell me how can I model a Gaussian Basis Function in a 2 Dimensional Space in order to obtain a scalar output?

I know how to apply this with a scalar input, but I don't understand how should I apply it to a 2 dimensional vector input. I've seen many variations of this that I am confused.

+1  A: 

With each Gaussian basis associate a center of the same dimension as the input, lets call it c. If x is your input, you can compute the output as

y = exp( - 0.5 * (x-c)'*(x-c) )

This will work with any dimension of x and c, provided they are the same. A more general form is

y = sqrt(det(S)) * exp( - 0.5 * (x-c)'* S * (x-c) )

where S is some positive definite matrix, well the inverse covariance matrix. A simple case is to take S to be a diagonal matrix with positive entries on the diagonals.

srean
But in the 2 - Dimensional case shouldn't I also calculate det(S), where S is the covariance for X, or could I just skip it?
Jack
@Jack For the two dimensional case I assumed S to be identity for simplicity. You could of course have an S matrix out there. Note that I am using S for the inverse of the covariance matrix, not the covariance matrix. If you want the output of the basis function to integrate to 1 then you need another 1/(2 * pi) multiplicative term. But for basis functions you usually do not need such constraints.
srean
A: 

To sample from a multivariate normal distribution, use the MVNRND function from the Statistics Toolbox. Example:

MU = [2 3];                    %# mean
COV = [1 1.5; 1.5 3];          %# covariance (can be isotropic/diagonal/full)
p = mvnrnd(MU, COV, 1000);     %# sample 1000 2D points
plot(p(:,1), p(:,2), '.')      %# plot them

alt text

Amro

related questions