您的位置:首页 > 编程语言 > MATLAB

matlab中normfit函数进行正太分布拟合

2016-11-21 10:01 1966 查看


一、简介

正态分布Normal distribution)又名高斯分布Gaussian distribution),是一个在数学物理工程领域都非常重要的概率分布,在统计学的许多方面有着重大的影响力。

随机变量X服从一个数学期望为μ、标准方差为σ2的高斯分布,记为:
X∼N(μ,σ2),
则其概率密度函数



正态分布的期望值μ决定了其位置,其标准差σ决定了分布的幅度。因其曲线呈钟形,因此人们又经常称之为钟形曲线。我们通常所说的标准正态分布是μ
= 0,σ = 1的正态分布。


二、代码

(1)pdf 和 cdf函数的说明、

Probability density function(PDF) 概率密度函数;  

cumulative distribution function ; CDF 是累积分布函数

(2)正态分布(normpdf normcdf)

[plain] view
plain copy

 





clc  

clear all  

close all  

dataall = load('G:\zyp_thanks\metro_test\1-07\529_2.csv');  

data = dataall(:,3);%指定列  

[mu,sigma]=normfit(data);%estimate of the mean and standard deviation in data  

[y,x]=hist(data,6);%creates a histogram bar plot of data,sorts data into the number of bins specified by nbins  

%return the categorical levels correponding to each count in N  

bar(x,y,'FaceColor','r','EdgeColor','w');box off  

xlim([mu-3*sigma,mu+3*sigma]) % sets the axis limits in the current axes to the specified values  

a2=axes;  

% computes the pdf at each of the values in X using the normal distribution  

% with mean and standard deviation sigma.  

ezplot(@(x)normpdf(x,mu,sigma),[mu-3*sigma,mu+3*sigma])  

set(a2,'box','off','yaxislocation','right','color','none')  

title '频数直方图与正态分布密度函数(拟合)'  



(3) quantile - quantile plot (Q-Q plot)

[plain] view
plain copy

 





clc  

clear all  

close all  

dataall = load('G:\zyp_thanks\metro_test\1-07\529_2.csv');  

data = dataall(:,3);%指定列  

qqplot(data);  

% displays a quantile-quantile plot of the sample quantiles of X versus  

% theoretical from a normal distribution. if the distribution of X is  

% normal,the plot will be close to linear.  

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: