function CLT_general( num_random_experiments, experiment_bound)
%CLT_GENERAL plots the distribution fcn of the sum of bdd rand exps
%   num_random_experiments = number of random experiments you wish to sum

%   experiment_bound = the bound on the sample space of the random
%       experiments you wish to run

experiment_bound1=randi(experiment_bound);
[random_sample_space1,random_distribution1]=...
    generate_random_experiment(experiment_bound1);
expected_value1=sum(random_sample_space1.*random_distribution1);
variance1=var(random_sample_space1,random_distribution1);

fprintf('your first random experiment \n press spacebar to continue \n \n')
figure(1);
plot(random_sample_space1,random_distribution1);
title('first random experiment')
pause


for i=1:num_random_experiments
    experiment_bound2=randi(experiment_bound);
    [random_sample_space2,random_distribution2]=...
    generate_random_experiment(experiment_bound2);
    
fprintf('your next new random experiment \n press spacebar to continue \n \n')
figure(2);
plot(random_sample_space2,random_distribution2);
title('new random experiment')
pause

    expected_value2=sum(random_sample_space2.*random_distribution2);
    variance2=var(random_sample_space2,random_distribution2);
    
    [random_sample_space1,random_distribution1]=...
        prob_convolve(random_sample_space1,random_distribution1,...
        random_sample_space2,random_distribution2);
    
    expected_value1=expected_value1+expected_value2;
    variance1=variance1+variance2;
    
    standardized_random_sample=...
        (random_sample_space1-expected_value1)./sqrt(variance1);
    standard_normal_distribution=...
        1/sqrt(2*pi).*exp(-(standardized_random_sample).^2/2);
    standardized_random_distribution=sqrt(variance1).*random_distribution1;
    
    fprintf('the sum of the random experiments so far and phi(x) \n press spacebar to continue \n \n')
    figure(3);
    plot(standardized_random_sample,standardized_random_distribution,...
        standardized_random_sample,standard_normal_distribution);
    title('the sum of the random experiments so far and phi(x)')
    pause

end


end

