Skip to content

Instantly share code, notes, and snippets.

@angusb
Created March 7, 2010 00:59
Show Gist options
  • Save angusb/324080 to your computer and use it in GitHub Desktop.
Save angusb/324080 to your computer and use it in GitHub Desktop.
function Gaussian()
h = .5;
d = 1;
hold on
load Hw3data2a.txt;
[n colSize] = size(Hw3data2a);
x = sort(Hw3data2a);
[f,xd] = ksdensity(x);
plot(xd,f);
minD = min(x);
maxD = max(x);
step = 0.05;
p_x = [];
for i = min(x):step:max(x)
fac = 1/((2*pi)^(d/2));
sum = 0;
for j = 1:n
foo = exp((-(i-x(j)^2))/(2*h^2));
sum = sum + (foo * fac);
end
ptild_x = sum/n;
p_x = [p_x ptild_x];
%plot(i, ptild_x)
end
hold off
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment