필터 지우기
필터 지우기

normal distribution from data

조회 수: 26 (최근 30일)
harley
harley 2013년 9월 10일
is there a more efficient way to derive a normal distribution.
% Deriving Normal Distribution From the Data
x=0:1:12;
m=mean(Data);
s=std(Data);
p=(1/(s*sqrt(2*pi)))*exp((-(x-m).^2)/(2*s^2));
  댓글 수: 5
Roger Stafford
Roger Stafford 2013년 9월 10일
Image Analyst, it isn't 'x' that Harley is stating has the normal distribution. It is 'data' which isn't being specified here. The 'x' is the independent variable in the hypothesized normal distribution. A plot of
plot(x,p)
would give the theoretical normal distribution pdf values as functions of x for the mean and std which have been computed from 'data'.
Image Analyst
Image Analyst 2013년 9월 10일
You're right - I messed up and thought that x was also the Data.

댓글을 달려면 로그인하십시오.

채택된 답변

Youssef  Khmou
Youssef Khmou 2013년 9월 10일
Here is another suggestion:
y=pdf('Normal',x,m,s);
plot(x,y);
  댓글 수: 2
Image Analyst
Image Analyst 2013년 9월 10일
It's fewer characters, so it's simpler to look at, but I doubt it's faster or more efficient (since there is more than one line of code inside that function), but I doubt he really wanted/needed more efficiency or speed anyway.
Youssef  Khmou
Youssef Khmou 2013년 9월 11일
Yes Mr @Image Analyst, the advantage i see is that this function gives a choice for other laws besides the Gaussian,

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Shashank Prasanna
Shashank Prasanna 2013년 9월 10일
편집: Shashank Prasanna 2013년 9월 10일
Since this is normal distribution, the mean and std of the data are the maximum likelihood estimates for the normal distribution from the data.
Once you have the PDF, like you have in the last line of code as 'p', you could plot the PDF using x to span -4*sigma to +4*sigma:
x = -4*s:0.01:4*s
p=(1/(s*sqrt(2*pi)))*exp((-(x-m).^2)/(2*s^2));
plot(x,p)
You could use a wider range if you wanted to.

Roger Stafford
Roger Stafford 2013년 9월 10일
You might try the Statistics Toolbox function 'normplot' to see how closely your 'data' comes to a normal distribution.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by