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

本文介绍了正态分布(也称为高斯分布)的基本概念及其在统计学中的应用,并通过MATLAB代码示例展示了如何进行正态分布的概率密度函数拟合与QQ图绘制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、简介

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

随机变量X服从一个数学期望μ标准方差σ2的高斯分布,记为:

XN(μ,σ2),

则其概率密度函数

f(x) = {1 \over \sigma\sqrt{2\pi} }\,e^{- {​{(x-\mu )^2 \over 2\sigma^2}}}

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

二、代码

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

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

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

(2)正态分布(normpdf normcdf)


[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. clc  
  2. clear all  
  3. close all  
  4. dataall = load('G:\zyp_thanks\metro_test\1-07\529_2.csv');  
  5. data = dataall(:,3);%指定列  
  6. [mu,sigma]=normfit(data);%estimate of the mean and standard deviation in data  
  7. [y,x]=hist(data,6);%creates a histogram bar plot of data,sorts data into the number of bins specified by nbins  
  8. %return the categorical levels correponding to each count in N  
  9. bar(x,y,'FaceColor','r','EdgeColor','w');box off  
  10. xlim([mu-3*sigma,mu+3*sigma]) % sets the axis limits in the current axes to the specified values  
  11. a2=axes;  
  12. % computes the pdf at each of the values in X using the normal distribution  
  13. % with mean and standard deviation sigma.  
  14. ezplot(@(x)normpdf(x,mu,sigma),[mu-3*sigma,mu+3*sigma])  
  15. set(a2,'box','off','yaxislocation','right','color','none')  
  16. title '频数直方图与正态分布密度函数(拟合)'  

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

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. clc  
  2. clear all  
  3. close all  
  4. dataall = load('G:\zyp_thanks\metro_test\1-07\529_2.csv');  
  5. data = dataall(:,3);%指定列  
  6. qqplot(data);  
  7. % displays a quantile-quantile plot of the sample quantiles of X versus  
  8. % theoretical from a normal distribution. if the distribution of X is  
  9. % normal,the plot will be close to linear.  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值