%%% moment by (Benign tumor) use _30_ raw data to randomly arrange and run 100 times (without replacement) %%%
B = xlsread('bbbMLE.csv') % 匯入 excel檔,xlsx檔也可以 %
% B =[0.5077,0.461,0.5292,0.4135,0.5116,0.4084,0.699,0.4736,0.4342,0.5986,0.5405,0.5032,0.5412,0.5363,0.5691,0.4574,0.4394,0.4985,0.4374,0.577,0.5556,0.4555,0.5421,0.6105,0.6032,0.6247,0.462,0.6012,0.6445,0.6283]; %
for k = 1:100, B1(k,:) = randperm (30) ; end % 取第k列,這裡 (k=1到100),所以要取1到100列 %
BMatrix = B(B1); BMatrix
B_training = BMatrix(:,1:21) % 取樣所有列1到21筆的資料,若僅要某一列將 (:) 設成該列數字即可 %
B_training_mean = mean (B_training,2) % 計算所有列1到21筆資料的平均數,2為列的總和,1為預設,用來求行的總和 %
B_testing = BMatrix(:,22:30) % 取樣所有列22筆到30筆的資料,若僅要某一列將 (:) 設成該列數字即可 %
B_testing_mean = mean (B_testing,2) % 計算所有列22到30筆資料的平均數,2為列的總和,1為預設,用來求行的總和 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BMatrix_change_to_vector = reshape (BMatrix',3000,1)
% 將10000筆資料轉換成單一向量(vector)也就是一整列或一整行,才能計算其 MLE 的值 %
mean_of_BMatrix = mean (BMatrix_change_to_vector)
% 求其總平均 %
median_of_BMatrix = median (BMatrix_change_to_vector)
% 求其中位數 %
max_of_BMatrix = max (BMatrix_change_to_vector)
% 求其最大值 %
min_of_BMatrix = min (BMatrix_change_to_vector)
% 求其最小值 %
mle_value_of_BMatrix = mle('Rayl',BMatrix_change_to_vector,100)
% 利用mle做100次,x2 = [phat,pci],100為實驗次數 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xlswrite('BMatrix.xls',BMatrix) % 將100*30矩陣的結果輸出成excel檔 %
xlswrite('B_training.xls',B_training) % 將training組的結果輸出成excel檔 %
xlswrite('B_training_mean.xls',B_training_mean) % 將training_mean組的結果輸出成excel檔 %
xlswrite('B_testing.xls',B_testing) % 將testing組的結果輸出成excel檔 %
xlswrite('B_testing_mean.xls',B_testing_mean) % 將training_mean組的結果輸出成excel檔 %
xlswrite('mle_value_of_BMatrix.xls',mle_value_of_BMatrix) % 將100*30矩陣的結果輸出成excel檔 %
%%% moment by (Malignant tumor) use _30_ raw data to randomly arrange and run 100 times (without replacement) %%%
M = xlsread('mmmMLE.csv') % 匯入 excel檔,xlsx檔也可以 %
% M = [0.5815,0.492,0.4972,0.5292,0.5833,0.5466,0.6748,0.4731,0.485,0.588,0.3856,0.5158,0.4531,0.4545,0.5451,0.5679,0.5735,0.4944,0.5408,0.4108,0.6561,0.662,0.5228,0.535,0.3262,0.5115,0.4567,0.56,0.6596,0.5545]; %
for j = 1:100, M1(j,:) = randperm (30) ; end % 取第j列,這裡 (j=1到100),所以要取1到100列 %
MMatrix = M(M1); MMatrix
M_training = MMatrix(:,1:21) % 取樣所有列1到21筆的資料,若僅要某一列將 (:) 設成該列數字即可 %
M_training_mean = mean (M_training,2) % 計算所有列1到21筆資料的平均數,2為列的總和,1為預設,用來求行的總和 %
M_testing = MMatrix(:,22:30) % 取樣所有列22筆到30筆的資料,若僅要某一列將 (:) 設成該列數字即可 %
M_testing_mean = mean (M_testing,2) % 計算所有列22到30筆資料的平均數,2為列的總和,1為預設,用來求行的總和 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MMatrix_change_to_vector = reshape (MMatrix',3000,1) % 將10000筆資料轉換成單一向量(vector)也就是一整列或一整行,才能計算其 MLE 的值 %
mean_of_MMatrix = mean (MMatrix_change_to_vector) % 求其總平均 %
median_of_MMatrix = median (MMatrix_change_to_vector) % 求其中位數 %
max_of_MMatrix = max (MMatrix_change_to_vector)
min_of_MMatrix = min (MMatrix_change_to_vector)
mle_value_of_MMatrix = mle('Rayl',MMatrix_change_to_vector,100) % 利用mle做100次,x2 = [phat,pci],100為實驗次數 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xlswrite('MMatrix.xls',MMatrix) % 將100*30矩陣的結果輸出成excel檔 %
xlswrite('M_training.xls',M_training) % 將training組的結果輸出成excel檔 %
xlswrite('M_training_mean.xls',M_training_mean) % 將training_mean組的結果輸出成excel檔 %
xlswrite('M_testing.xls',M_testing) % 將testing組的結果輸出成excel檔 %
xlswrite('M_testing_mean.xls',M_testing_mean) % 將testing_mean組的結果輸出成excel檔 %
xlswrite('mle_value_of_BMatrix.xls',mle_value_of_MMatrix) % 將100*30矩陣的結果輸出成excel檔 %
histfit (B_training_mean) % 畫出training組100個平均數的直方圖 %
histfit (B_testing_mean) % 畫出testing組100個平均數的直方圖 %
histfit (M_training_mean) % 畫出training組100個平均數的直方圖 %
histfit (M_testing_mean) % 畫出testing組100個平均數的直方圖 %
histfit (BMatrix_change_to_vector) % 畫出testing組100個平均數的直方圖 %
histfit (MMatrix_change_to_vector) % 畫出testing組100個平均數的直方圖 %
%%% randomly generate matrix of 100*100 by Rayleigh distribution (omega = 1) %%%
data = raylrnd(1,100,100); data
% rnd是隨機取樣,根據Rayleigh分配,隨機產生100*100的矩陣,1為參數omega %
%%% another way to get random sample from Rayleigh (omega=1) _ r = random('Nakagami',1,100,100),,rayl可改成其他分配 %%%
data_change_to_vector = reshape (data',10000,1)
% 將10000筆資料轉換成單一向量(vector)也就是一整列或一整行,才能計算其 MLE 的值 %
value10000_of_mle = mle('Rayl',data_change_to_vector)
% 利用mle做100次,x2 = [phat,pci],100為實驗次數 %
histfit (data_change_to_vector ,20,'Rayl')
% 畫出此隨機樣本平均數的直方圖,20為所需的條數 %
x = mean (data)
% 求出10列的平均數 %
xlswrite('data_raw_random.xls',data)
% 將training組的結果輸出成excel檔 %
xlswrite('data_change_to_vector.xls',data_change_to_vector)
% 將training組的結果輸出成excel檔 %
%%%% ___________________________________________________做比較 _________________________________________________________%%%
data1 = raylrnd(1,10,10); data1
data1_change_to_vector = reshape (data1',100,1)
% 將10000筆資料轉換成單一向量(vector)也就是一整列或一整行,才能計算其 MLE 的值 %
value100_of_mle = mle('Rayl',data1_change_to_vector)
% 利用mle做100次,x2 = [phat,pci],100為實驗次數 %
histfit (data1_change_to_vector ,20,'Rayl')
phat = mle(data,'distribution','Nakagami');
data = random('naka'1,1,10,10); data
data_change_to_vector = reshape (data',10000,1)
value10000_of_mle = mle('Rayl',data_change_to_vector)
value10000_of_mle = mle('Rayl',data_change_to_vector)