function [y] = vonmises(X, mu, kappa)

dims = size(X);
X = X(:);

if (length(mu) > length(kappa))
    kappa = repmat(kappa, [length(mu), 1]);
elseif (length(kappa) > length(mu))
    mu = repmat(mu, [length(kappa), 1]);
end

y = zeros(length(X), length(mu));

for a = 1:length(mu)
    y(:, a) = exp(kappa(a)*cos(X-mu(a)));
    y(:, a) = y(:, a)/max(y(:, a));
end


y = reshape(y, dims);

end



