 |
ความคิดเห็นที่ 7 |
ขอบคุณ คุณ Ni-MH ที่ลองเขียนโปรแกรมตรวจสอบครับ
ผมเองก็กำลังหัดเขียนโปรแกรมอยู่ (ด้วย MATLAB)
ข้างล่างคือ โค้ท เผื่อใคร สนใจนำไปลอง run clear; close all; N=20; % N = Number of questions in a test P=5000; % Repeat the test P times np=[]; % np contains score (N = 100%) of each test for i=1:P correct_answer=ceil(4.*rand(N,1)); % Generate correct answer 1,2,3, or 4. answer=ceil(4.*rand(N,1)); % Generate answer by testee 1,2,3, or 4. np=[np sum(correct_answer==answer)*100/N]; end % Answer prob=sum(np>=50)/P
% Plot the simulation result figure; bar(np,'r'); axis([0 P+1 0 100]); grid on; title(strcat('Number of questions: ',num2str(N),' , Repeat:',num2str(P),' times')); xlabel('Test no.'); ylabel('Score (%)'); figure; hist(np,0:(100/N):100); axis([0 100 0 P/2]); grid on; title(strcat('Histogram (Number of questions: ',num2str(N),' , Repeat:',num2str(P),' times)')); ylabel('Count'); xlabel('Score (%)');
ได้ผลดังรูป
จากคุณ |
:
nonlocality
|
เขียนเมื่อ |
:
3 ก.พ. 53 23:52:54
|
|
|
|
 |