function yy = nngp (H,N)
% yy = nngp (H,[N])
% Experiments in Neal (1996) to show NN to GP.
% $Id: nngp.m,v 1.1 2017/08/13 12:48:42 daichi Exp $
if nargin < 2
  N = 1000;
end
% prepare
xx = [-0.2 0.4];
yy = zeros(N,length(xx));
% body
for n = 1:N
  U = randn(1,H) * 5;
  W = randn(1,H) * 5 / sqrt(H);
  b = randn(1,H) * 0.1;
  for i = 1:length(xx)
    x = xx(i);
    % h = sigmoid(x * U + b);
    % h = tanh (x * U + b);
    h = step (x * U + b);
    y = sum (W .* h);
    yy(n,i) = y;
  end
end

scatter(yy(:,1),yy(:,2),'filled');
axis([-15 15 -15 15]);

