{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

BENG 449 problem 2 6 Script

# BENG 449 problem 2 6 Script - counter = 1 for i =...

This preview shows page 1. Sign up to view the full content.

2/7/08 9:21 PM MATLAB Command Window 1 of 1 >> % BENG 449 -- Problem Set 2, Question 6 % Written by Alex Lemon % The following script uses the central limit theorem % to generate Gaussian numbers (see attached for % explanation). num_gauss = 10000; n = 1000; sigma = 1; mu = 0; clear z; for i = 1:num_gauss; x_values = rand(1, n); z(i) = (sum(x_values) - 1/2 * n) / sqrt(n / 12); z(i) = sigma * z(i) + mu; end clear filtered_data % Create a histogram of the Gaussian numbers minimum_bin = mu - 3 * sigma; maximum_bin = mu + 3 * sigma; delta_bin = 0.05; bins = minimum_bin:delta_bin:maximum_bin;
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: counter = 1; for i = 1:length(z) current = z(i); if (abs(current - mu) < 3 * sigma) filtered_data(counter) = current; counter = counter + 1; end end hist(filtered_data, bins); title(['Histogram of Gaussian Random Variables (', . .. num2str(num_gauss), ' trials, n = ', . .. num2str(n), ')']); xlabel('z'); ylabel('Observed Frequency, f(z)'); hold on; z_values = minimum_bin:(delta_bin / 100):maximum_bin; plot(z_values, delta_bin * num_gauss * normpdf((z_values - mu)/sigma)); hold off; >>...
View Full Document

{[ snackBarMessage ]}