function die_nstar_distribution_compare_nd(sides_of_die,n )
%DIE_NSTAR_DISTRIBUTION_COMPARE_ND compares the distribution of S_n to phi
%     THERE ARE NO OUTPUTS FROM THIS PROGRAM

%makes a die of length sides_of_die
die=1:sides_of_die;

%initializes a place to hold the distribution for the die to all zeros
die_distribution=zeros(size(die));

%gives the die the uniform distribution
die_distribution(die_distribution==0)=1/sides_of_die;

%calculates the relevant quantities of the die given it's distribution.
expected_value=mean(die);
variance=var(die,die_distribution);

%makes a call to a function that creates the actual sample space and
%distribution of the experiment "roll the die n times and sum the
%outcomes." Probe get_distribution_sum to see how that works.
[S_n_sample,S_n_distribution]=get_distribution_sum(die,die_distribution,n);

%gets the standaridized sample space of S_n
S_n_star_sample=(S_n_sample-n*expected_value)*1/sqrt(n*variance);

%over this standardized sample space, this vector holds the value of the
%standard normal distribution. This is what we compare our distribution to.
standard_normal_distribution=1/sqrt(2*pi)*exp(-(S_n_star_sample).^2/2);

%we scale S_n_distribution by the square roote of n times the variance as
%in the text. 
scaled_S_n_distribution=S_n_distribution*sqrt(n*variance);

%plots the comparison.
figure(1); 
plot(S_n_star_sample,scaled_S_n_distribution,...
    S_n_star_sample,standard_normal_distribution);

end

