Thread: Hw5
View Single Post
  #1  
Old 05-12-2011, 11:16 AM
Yanan Yanan is offline
Member
 
Join Date: Jan 2011
Posts: 15
Default Hw5

Proof for Problem 1 is attached. Code for Problem 2.
Code:
data = load('hw5_data.txt','-ASCII');
[N,M] = size(data);

% mu and sigma
mu = mean(data);
sigma = cov(data);

%chi-square and p-value
chi2 = zeros(N,1);
p = zeros(N,1);
for i = 1:N
    chi2(i) = (data(i,:)-mu)*inv(sigma)*(data(i,:)-mu)';
    p(i) = 1-chi2cdf(chi2(i),5);
end

%FDR
[rank, index] = sort(p);
alpha = 0.1;
rej = [];
j = 1;
for i = 1:N
    if p(index(i)) < i*alpha/N
        rej(j) = index(i);
        j = j+1;
    end
end
Attached Images
File Type: pdf hw5.sol.pdf (281.7 KB, 863 views)
Reply With Quote