Created
March 7, 2010 00:59
-
-
Save angusb/324080 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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