{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

BENG 449 Problem 3 6

# BENG 449 Problem 3 6 - Store the t-statistics and test...

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

2/14/08 10:15 PM MATLAB Command Window 1 of 1 >> % BENG 449 -- Problem Set 3, Question 6 % Written by Alex Lemon sample_size = 10; num_trials = 10000; mu_1 = 9; mu_2 = 15; sigma = 10; test_results1 = zeros(1, num_trials); test_results2 = zeros(1, num_trials); t_statistics1 = zeros(1, num_trials); t_statistics2 = zeros(1, num_trials); for i = 1:num_trials % Generate random data sets from N(mu_1, sigma) and % N(mu_2, sigma) data1 = mu_1 + sigma * randn(1, sample_size); data2 = mu_2 + sigma * randn(1, sample_size); % Perform one-sided and two-sided difference of means % t-tests [h1, p1, ci1, stats1] = ttest(data1, data2, 0.05, 'left'); [h2, p2, ci2, stats2] = ttest(data1, data2, 0.05, 'both');
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % Store the t-statistics and test results t_statistics1(i) = stats1.tstat; t_statistics2(i) = stats2.tstat; test_results1(i) = h1; test_results2(i) = h2; end rejection_fraction1 = sum(test_results1) / length(test_results1); rejection_fraction2 = sum(test_results2) / length(test_results2); disp([' ']); disp(['The rejection fraction for the one-sided test is ', . .. num2str(rejection_fraction1)]); disp(['The rejection fraction for the two-sided test is ', . .. num2str(rejection_fraction2)]); The rejection fraction for the one-sided test is 0.3327 The rejection fraction for the two-sided test is 0.2191 >>...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online