使用方法:
[muhat, sigmahat] = normfit(data)
[muhat, sigmahat, muci, sigmaci] = normfit(data)
[muhat, sigmahat, muci, sigmaci] = normfit(data, alpha)
[...] = normfit(data, alpha, censoring)
[...] = normfit(data, alpha, censoring, freq)
[...] = normfit(data, alpha, censoring, freq, options)
說明:
[muhat, sigmahat] = normfit(data) 返回給定數(shù)據(jù)data的正態(tài)分布均值μ 和標(biāo)準(zhǔn)差σ
的參數(shù)估計(jì),。
[muhat, sigmahat, muci, sigmaci] = normfit(data, alpha)
返回置信度區(qū)間為100(1 - alpha) % 的參數(shù)估計(jì),這里alpha 是一個[0
1]范圍內(nèi)的值,,由置信區(qū)間寬度決定,。默認(rèn)alpha 是0.05,對應(yīng)95%的置信度區(qū)間,。
=================================================================================================
matlab中normfit在正態(tài)分布中的使用技巧如下:
函數(shù) normfit
格式 [muhat,sigmahat,muci,sigmaci] = normfit(X)
[muhat,sigmahat,muci,sigmaci] = normfit(X,alpha)
說明
muhat,sigmahat分別為正態(tài)分布的參數(shù)μ和σ的估計(jì)值,muci,sigmaci分別為置信區(qū)間,其置信度為;alpha給出顯著水平α,缺省時默認(rèn)為0.05,即置信度為95%.
例4-62 有兩組(每組100個元素)正態(tài)隨機(jī)數(shù)據(jù),其均值為10,均方差為2,求95%的置信區(qū)間和參數(shù)估計(jì)值.
解:>>r = normrnd (10,2,100,2);
%產(chǎn)生兩列正態(tài)隨機(jī)數(shù)據(jù)
>>[mu,sigma,muci,sigmaci] =
normfit(r)
則結(jié)果為
mu =
10.1455 10.0527 %各列的均值的估計(jì)值
sigma =
1.9072 2.1256 %各列的均方差的估計(jì)值
muci =
9.7652 9.6288
10.5258 10.4766
sigmaci =
1.6745 1.8663
2.2155 2.4693
說明 muci,sigmaci中各列分別為原隨機(jī)數(shù)據(jù)各列估計(jì)值的置信區(qū)間,置信度為95%.
例4-63 分別使用金球和鉑球測定引力常數(shù)
(1)用金球測定觀察值為:6.683 6.681 6.676 6.678 6.679 6.672
(2)用鉑球測定觀察值為:6.661 6.661 6.667 6.667 6.664
設(shè)測定值總體為,μ和σ為未知.對(1),(2)兩種情況分別求μ和σ的置信度為0.9的置信區(qū)間.
解:建立M文件:LX0833.m
X=[6.683 6.681 6.676 6.678 6.679 6.672];
Y=[6.661 6.661 6.667 6.667 6.664];
[mu,sigma,muci,sigmaci]=normfit(X,0.1) %金球測定的估計(jì)
[MU,SIGMA,MUCI,SIGMACI]=normfit(Y,0.1) %鉑球測定的估計(jì)
運(yùn)行后結(jié)果顯示如下:
mu =
6.6782
sigma =
0.0039
muci =
6.6750
6.6813
sigmaci =
0.0026
0.0081
MU =
6.6640
SIGMA =
0.0030
MUCI =
6.6611
6.6669
SIGMACI =
0.0019
0.0071
由上可知,金球測定的μ估計(jì)值為6.6782,置信區(qū)間為[6.6750,6.6813];
σ的估計(jì)值為0.0039,置信區(qū)間為[0.0026,0.0081].
泊球測定的μ估計(jì)值為6.6640,置信區(qū)間為[6.6611,6.6669];
σ的估計(jì)值為0.0030,置信區(qū)間為[0.0019,0.0071].
===============================================================================================
而normpdf是求概率密度函數(shù)
normpdf - Normal probability density
function
Syntax
Y = normpdf(X,mu,sigma)
Y = normpdf(X)
Y = normpdf(X,mu)
Description
Y =
normpdf(X,mu,sigma) computes the pdf at each of the values in
X using the normal distribution with mean mu and
standard deviation sigma. X, mu, and
sigma can be vectors, matrices, or multidimensional arrays
that all have the same size. A scalar input is expanded to a
constant array with the same dimensions as the other inputs. The
parameters in sigma must be positive.
The normal pdf is
The likelihood function is the pdf viewed
as a function of the parameters. Maximum likelihood estimators
(MLEs) are the values of the parameters that maximize the
likelihood function for a fixed value of x.
The standard normal distribution has
μ = 0 and σ = 1.
If x is standard normal, then
xσ + μ is also normal with mean
μ and standard deviation σ. Conversely, if
y is normal with mean μ and standard
deviation σ, then x =
(y-μ) / σ
is standard normal.
Y = normpdf(X) uses the standard normal distribution
(mu = 0,
sigma = 1).
Y = normpdf(X,mu) uses the normal distribution with
unit standard deviation
(sigma = 1).
Examples
mu = [0:0.1:2];
[y i] = max(normpdf(1.5,mu,1));
MLE = mu(i)
MLE =
1.5000
|