BENG 449 Problem 2 3 A

# BENG 449 Problem 2 3 A - .....

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

2/7/08 4:55 PM MATLAB Command Window 1 of 1 >> % BENG 449 -- Problem Set 2, Question 3 (Part 1) % Written by Alex Lemon % Simulate n = 100 realizations of a Gaussian random variable % X with mu = 1, sigma = 1. n = 100; mu = 1; sigma = 1; x_realizations = zeros(1, n); for n = 1:100 x_realizations(n) = randn() * sigma + mu; end % Calculate the sample and the sample median disp([' ']); disp(['The sample mean of the X realizations is ', . .. num2str(mean(x_realizations))]); disp(['The sample median of the X realizations is ', .
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: .. num2str(median(x_realizations))]); % Repeat 100 times num_rep = 100; sample_means = zeros(1, num_rep); sample_medians = zeros(1, num_rep); for repetitions = 1:num_rep for n = 1:100 x_realizations(n) = randn() * sigma + mu; end sample_means(repetitions) = mean(x_realizations); sample_medians(repetitions) = median(x_realizations); end The sample mean of the X realizations is 1.0293 The sample median of the X realizations is 1.0158 >>...
View Full Document

## This note was uploaded on 07/19/2008 for the course BENG 449 taught by Professor Richardcarson during the Spring '08 term at Yale.

Ask a homework question - tutors are online