2014-06-19 2 views
-2

이 코드를 작성했습니다 :.Matlab 및 정상 인식

N=10000; % number of experiments 
o= 1000+randn(1,N)*sqrt(10^4); % random normal distribution with mean 1000 and variance 10^4 
b=700:50:1300; % specify the number of bins (possible values of the realizations) 
prob=hist(o,b)/N %create ad histogram 

X = 700 : 50 : 1300] ** 지금

, I는 B 및 prob는의 값을 포함하는 매트릭스를 생성 할 수 있는가? 즉,이 종류의 행렬을 원합니다.

행렬 = [X의 값 (i); X (i)의 값에서의 확률 연관]]

es : matrix = [... X (i) = 850 ...; ... prob (X (i) = 850) ..]

고맙습니다! ;)

+3

어떤 _single_에 관련된 확률 값은 0입니다. 원하는 것을 재고해야합니다. –

+0

0이 아닙니다. 스크립트를 실행하면 probabili 의. 내 유일한 문제는 매트릭스에 저장하는 것입니다. – user1595513

+1

It _is_ 0. 귀하의 스크립트는 _intervals_ 확률을 제공합니다 –

답변

1

난 당신이 히스토그램 계산되는의 간격의 확률을 원한다고 생각 :

N = 100000; %// number of experiments 
b = 700:50:1300; %// bin centers 
mu = 1000; %// mean of distribution 
sigma = 100; %// standard deviation of distribution 

delta = (b(2)-b(1))/2; %// compute bin half-width 
pb = normcdf(b+delta,mu,sigma)-normcdf(b-delta,mu,sigma); %// compute probability 

확인 :

o = mu + sigma*randn(1,N); 
hist(o, b) 
hold on 
plot(b, N*pb, 'r', 'linewidth', 2) 

enter image description here