% How does hypersphere volume scale with the number of dimensions?
% function test1

for m = 1:20
   N(m) = m;  % Number of dimensions
   volume(m) = hypersphere1(N(m), 1e6);
end

figure(1)
plot(N, answer(N), 'k-', N, volume,'bo')
title('Volume of the N-dimensional unit hypersphere','fontsize',18)
legend('analytic answer','MonteCarlo (N = 10^6)')
xlabel('Number of dimensions, N','fontsize',16)
ylabel('Volume','fontsize',16)

% How does p, the volume filling factor (hypersphere/hypercube),
% change with the number of dimensions
figure(2)
p = answer(N) ./ (2.^N);
semilogy(N, p, 'k-', N, volume./(2.^N), 'bo')
title('Volume filling factor of hypersphere inscribed in hypercube','fontsize',18)
legend('analytic answer','MonteCarlo (N = 10^6)')
xlabel('Number of dimensions, N','fontsize',16)
ylabel('p (vol ratio hypersphere/hypercube)','fontsize',16)
