% % example 219 % % Written by: % -- % John L. Weatherwax 2008-02-20 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clear all; close all; clc; addpath('../../Code/CSTool'); load mcdata; % n = length(mcdata); % assume we know the population sigma: sigma = 7.8; % this implies we know the standard deviation of the sample mean: sigxbar = sigma/sqrt(n); % get the observed value of the test statistic: Tobs = (mean(mcdata)-454)/sigxbar; disp( 'our observed test statistic is...' ); Tobs % perform a monte-carlo simulation (where we generate a random sample under H_0) % used to determine the distribution of our test statistic: M = 1000; Tm = zeros(1,M); for i=1:M, xs = sigma*randn(1,n) + 454; Tm(i) = (mean(xs)-454)/sigxbar; end % pick a significance level: alpha = 0.1; % find the \hat{q}_{\alpha/2} and \hat{q}_{1-\alpha/2} quantiles for our statistic T (under H_0): %qhat = sample_quantiles_linInterp(Tm,[0.5*alpha, 1-0.5*alpha]); disp( 'the qhat quantiles are...' ); qhat = csquantiles(Tm,[0.5*alpha, 1-0.5*alpha])