
After being stupid (trying to be clever with the indices, but being too clever) I developed a dynamic programming solution to the peg network problem. The figure on the left shows the what happens if we fit the results to a Gaussian distribution; we get excellent agreement, with small residuals. However, the residuals are not randomly distributed about zero, which usually provides information of a systematic error. I don't have an explanation for why those features showed up.
function [pdf grid data ]= DPSol(n)
if mod(n,2) == 0
n = n +1;
end
grid = gridSetup(n+2);
p = 0.5;
pdf = zeros(n,2*n+1);
mid = ceil(length(pdf(1,:))/2);
pdf(1,mid) = 1.0;
for j = 2:n
for i=(mid-j+1):(mid+j-1)
if(mod(j,2)==0)
if( mod(i,2) == 1)
pdf(j,i) = (pdf(j-1,i-1)+pdf(j-1,i+1))*rand;
end
else
if( mod(i,2) == 0)
pdf(j,i) = (pdf(j-1,i-1)+pdf(j-1,i+1))*rand;
end
end
end
end

In the version I used to derive the graph I used a constant probability of 0.5, the following figure was produced using a random probability at each intersection. You can see the initial spike at the first node of 1.0, and after that it all seems to die out as the ball progresses its way down the network.
No comments:
Post a Comment