数学建模培训2012-MATLAB统计(3)

2019-01-12 12:43

normstat Mean and variance for the normal distribution poisstat Mean and variance for the Poisson distribution raylstat Mean and variance for the Rayleigh distribution tstat Mean and variance for the Student's t distribution

unidstat Mean and variance for the discrete uniform distribution unifstat Mean and variance for the continuous uniform distribution wblstat Mean and variance for the Weibull distribution 例如:正态分布的矩

调用格式为:[M,V] = normstat(mu,sigma)

n = 1:5;

[m,v] = normstat(n'*n,n'*n)

m =

1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 10 15 20 25 v =

1 4 9 16 25 4 16 36 64 100 9 36 81 144 225 16 64 144 256 400 25 100 225 400 625

1.6附录:随机变量的分布函数

概率分布工具: disttool 随机数产生工具:randtool

二、参数估计

1参数估计、置信区间与极大似然估计函数列表

betafit Parameter estimates and confidence intervals for beta distributed data betalike Negative beta log-likelihood function

binofit Parameter estimates and confidence intervals for binomial data dfittool Interactive tool for fitting distributions to data

evfit Parameter estimates and confidence intervals for extreme value data evlike Negative log-likelihood for the extreme value distribution

expfit Parameter estimates and confidence intervals for exponential data explike Negative log-likelihood for the exponential distribution

gamfit Parameter estimates and confidence intervals for gamma distributed data gamlike Negative gamma log-likelihood function

gevlike Negative log-likelihood for the generalized extreme value distribution

gplike Negative log-likelihood for the generalized Pareto distribution lognfit Parameter estimates and confidence intervals for lognormal data lognlike Negative log-likelihood for the lognormal distribution mle Maximum likelihood estimation

nbinfit Parameter estimates and confidence intervals for negative binomial data normfit Parameter estimates and confidence intervals for normal data normlike Negative normal log-likelihood function

poissfit Parameter estimates and confidence intervals for Poisson data raylfit Parameter estimates and confidence intervals for Rayleigh data unifit Parameter estimates for uniformly distributed data

wblfit Parameter estimates and confidence intervals for Weibull data wbllike Weibull negative log-likelihood function

2举例

例1:正态分布的参数估计,置信区间 normfit 调用格式:

[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)

censoring是一个 Boolean向量,与数据同维,1表示数据右删失,0表示为正常的观测值。 freq表示不同组合的频数

data = normrnd(10,2,100,2);

[mu,sigma,muci,sigmaci] = normfit(data)

例2:正态分布的极大似然估计 normlike

nlogL = normlike(params,data)

[nlogL,AVAR] = normlike(params,data) [...] = normlike(param, data, censoring)

[...] = normlike(param, data, censoring, freq)

n?,??2) nlogL = normlike(params,data) 返回值为?log?p(xi;?i?1[nlogL,AVAR] = normlike(params,data) 返回值中多了一项 AVAR,它是Fisher信息矩阵的逆。其对

角线上的元素为估计参数的渐近方差的估计。其中的Fisher信息矩阵是基于数据的Fisher信息矩阵,而非定义中的期望估计。

x=normrnd(2,3,100,1); [a,b]=normfit(x); param=[a b];

[nlogL,avar]=normlike(param,x)

三、统计作图

addedvarplot Create added-variable plot for stepwise regression boxplot Box plots of a data sample

cdfplot Plot of empirical cumulative distribution function ecdfhist Create histogram from output of ecdf errorbar Plot error bars along a curve

fsurfht Interactive contour plot of a function gline Interactively draw a line in a figure

gname Label plotted points with their case names or case number gplotmatrix Plot matrix of scatter plots by group gscatter Scatter plot by group lsline Least squares fit line(s)

normplot Normal probability plot for graphical normality testing pareto Pareto charts for statistical process control qqplot Quantile-quantile plot of two samples rcoplot Residual case order plot

refcurve Add a polynomial curve to the current plot refline Add a reference line to the current axes surfht Interactive contour plot wblplot Weibull probability plot 例如 boxplot

load carsmall

boxplot(MPG, Origin)

x1 = normrnd(5,1,100,1); x2 = normrnd(6,1,100,1);

boxplot([x1,x2],'notch','on')

boxplot([x1,x2],'notch','on','whisker',1)

cdfplot cdfplot(X) H = cdfplot(X)

[h,stats] = cdfplot(X)

x = normrnd(0,1,50,1); cdfplot(x)

errorbar

lambda = (0.1:0.2:0.5);

r = poissrnd(lambda(ones(50,1),:)); [p,pci] = poissfit(r,0.001); L = p - pci(1,:) U = pci(2,:) - p

errorbar(1:3,p,L,U,'+')

gplotmatrix

gplotmatrix(x,y,g)

gplotmatrix(x,y,g,'clr','sym',siz)

gplotmatrix(x,y,g,'clr','sym',siz,'doleg')

gplotmatrix(x,y,g,'clr','sym',siz,'doleg','dispopt')

gplotmatrix(x,y,g,'clr','sym',siz,'doleg','dispopt','xnam','ynam') [h,ax,bigax] = gplotmatrix(...)

gplotmatrix(x,y,g) creates a matrix of scatter plots. Each individual set of axes in the resulting figure contains a scatter plot of a column of x against a column of y. All plots are grouped by the grouping variable g.

x and y are matrices with the same number of rows. If x has p columns and y has q columns, the figure contains a p-by-q matrix of scatter plots. If you omit y or specify it as the empty matrix, [], gplotmatrix creates a square matrix of scatter plots of columns of x against each other.

g is a grouping variable that can be a vector, string array, or cell array of strings. g must have the same

number of rows as x and y. Points with the same value of g are placed in the same group, and appear on the graph with the same marker and color. Alternatively, g can be a cell array containing several grouping variables (such as {G1 G2 G3}); in that case, observations are in the same group if they have common values of all grouping variables.

gplotmatrix(x,y,g,'clr','sym',siz) specifies the color, marker type, and size for each group. 'clr' is a string array of colors recognized by the plot function. The default is 'clr' = 'bgrcmyk'. 'sym' is a string array of symbols recognized by the plot command, with the default value '.'. siz is a vector of sizes, with the default determined by the 'defaultlinemarkersize' property. If you do not specify enough values for all groups, gplotmatrix cycles through the specified values as needed.

gplotmatrix(x,y,g,'clr','sym',siz,'doleg') controls whether a legend is displayed on the graph ('doleg'= 'on', the default) or not ('doleg'= 'off').

gplotmatrix(x,y,g,'clr','sym',siz,'doleg','dispopt') controls what appears along the diagonal of a plot matrix of y versus x. Allowable values are 'none', to leave the diagonals blank, 'hist' (the default), to plot histograms, or 'variable', to write the variable names.

gplotmatrix(x,y,g,'clr','sym',siz,'doleg','dispopt','xnam','ynam') specifies the names of the columns in the x and y arrays. These names are used to label the x- and y-axes. 'xnam' and 'ynam' must be character arrays or cell arrays of strings, with one name for each column of x and y, respectively.

[h,ax,bigax] = gplotmatrix(...) returns three arrays of handles. h is an array of handles to the lines on the graphs. The array's third dimension corresponds to groups in G. ax is a matrix of handles to the axes of the individual plots. If 'dispopt' is 'hist', ax contains one extra row of handles to invisible axes in which the

histograms are plotted. bigax is a handle to big (invisible) axes framing the entire plot matrix. bigax is fixed to point to the current axes, so a subsequent title, xlabel, or ylabel command

load discrim

gplotmatrix(ratings(:,1:3),ratings(:,4:7),group)

gplotmatrix(ratings(:,1:3),ratings(:,4:7),group,'br','.o',[],'on','',categories(1:3,:), categories(4:7,:))

gscatter

gscatter(x,y,g)

gscatter(x,y,g,'clr','sym',siz)

gscatter(x,y,g,'clr','sym',siz,'doleg')

gscatter(x,y,g,'clr','sym',siz,'doleg','xnam','ynam') h = gscatter(...)

Description

gscatter(x,y,g) creates a scatter plot of x and y, grouped by g, where x and y are vectors with the same size and g can be a vector, string array, or cell array of strings. Points with the same value of g are placed in the same group, and appear on the graph with the same marker and color. Alternatively, g can be a cell array containing several grouping variables (such as {G1 G2 G3}); in that case, observations are in the same group if they have common values of all grouping variables.

gscatter(x,y,g,'clr','sym',siz) specifies the color, marker type, and size for each group. 'clr' is a string array of colors recognized by the plot function. The default is 'clr' = 'bgrcmyk'. 'sym' is a string array of symbols recognized by the plot command, with the default value '.'. siz is a vector of sizes, with the default determined by the 'defaultlinemarkersize' property. If you do not specify enough values for all groups, gscatter cycles through the specified values as needed.

gscatter(x,y,g,'clr','sym',siz,'doleg') controls whether a legend is displayed on the graph ('doleg'= 'on', the default) or not ('doleg'= 'off').

gscatter(x,y,g,'clr','sym',siz,'doleg','xnam','ynam') specifies the name to use for the x-axis and y-axis labels. If the x and y inputs are simple variable names and xnam and ynam are omitted, gscatter labels the axes with the variable names.

h = gscatter(...) returns an array of handles to the lines on the graph.

load discrim

gscatter(ratings(:,1),ratings(:,2),group,'br','xo')

lsline

y = [2 3.4 5.6 8 11 12.3 13.8 16 18.8 19.9]'; plot(y,'+'); lsline;

normplot

x = normrnd(0,1,50,1); h = normplot(x);

qqplot

x = normrnd(0,1,100,1); y = normrnd(0.5,2,50,1); qqplot(x,y);


数学建模培训2012-MATLAB统计(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:浅析大学生诚信教育体系构建方法和途径

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: