Created
March 8, 2010 03:30
-
-
Save angusb/324815 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 ParzenBiVarUp() | |
h = .5; | |
d = 2; | |
load Hw3data2c.txt | |
[n colSize] = size(Hw3data2c); | |
input = Hw3data2c; | |
minD_x = min(Hw3data2c(:,1)); | |
maxD_x = max(Hw3data2c(:,1)); | |
minD_y = min(Hw3data2c(:,2)); | |
maxD_y = max(Hw3data2c(:,2)); | |
step = .1 | |
mesh_min = 0; | |
mesh_max = 0; | |
if (minD_x < minD_y) | |
mesh_min = minD_x; | |
else | |
mesh_min = minD_y; | |
end | |
if (maxD_x < maxD_y) | |
mesh_max = maxD_y; | |
else | |
mesh_max = maxD_x; | |
end | |
[X Y] = meshgrid(mesh_min:step:mesh_max); | |
[meshRows meshCols] = size(X); | |
out = zeros(meshRows, meshCols); | |
for i = 1:meshRows*meshCols | |
sum = 0; | |
for j = 1:n | |
foo = [X(i) Y(i)]; | |
bar = (foo - input(j))./h; | |
sum = sum + kernel(bar, d); | |
end | |
ptild_xy = (1/(n * h.^d))*(sum); | |
out(i) = ptild_xy; | |
end | |
surfc(X, Y, out); | |
colormap hsv | |
end | |
function h_u = kernel(u, d) | |
h_u = 1; | |
for i = 1:d | |
if (abs(u(i)) > 0.5) | |
h_u = 0; | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment