cdf
Cumulative distribution function
Syntax
描述
y = cdf(___,'upper')
returns the complement of the cdf using an algorithm that more accurately computes the extreme upper-tail probabilities.'上'
can follow any of the input arguments in the previous syntaxes.
例子
通过指定分布名称和参数来计算正态分布CDF
Compute the cdf values for a normal distribution by specifying the distribution name'Normal'
and the distribution parameters.
Define the input vectorxto contain the values at which to calculate the cdf.
x = [-2,-1,0,1,2];
计算平均值的正态分布的CDF值 等于1和标准偏差 等于5。
mu = 1; sigma = 5; y = cdf('Normal',x,mu,sigma)
y =1×50.2743 0.3446 0.4207 0.5000 0.5793
每个值INycorresponds to a value in the input vectorx. For example, at the valuexequal to 1, the corresponding cdf valueyis equal to 0.5000.
Compute Normal Distribution cdf Using Distribution Object
创建正态分布对象,并使用对象计算正态分布的CDF值。
Create a normal distribution object with the mean 等于1和标准偏差 等于5。
mu = 1; sigma = 5; pd = makedist('Normal','mu',亩,'sigma',Sigma);
Define the input vectorxto contain the values at which to calculate the cdf.
x = [-2,-1,0,1,2];
Compute the cdf values for the normal distribution at the values inx.
y = cdf(pd,x)
y =1×50.2743 0.3446 0.4207 0.5000 0.5793
每个值INycorresponds to a value in the input vectorx. For example, at the valuexequal to 1, the corresponding cdf valueyis equal to 0.5000.
计算泊松分布CDF
Create a Poisson distribution object with the rate parameter, , equal to 2.
lambda = 2;PD = Makedist(“泊松”,'lambda',lambda);
Define the input vectorxto contain the values at which to calculate the cdf.
x = [0,1,2,3,4];
Compute the cdf values for the Poisson distribution at the values inx.
y = cdf(pd,x)
y =1×50.1353 0.4060 0.6767 0.8571 0.9473
每个值INycorresponds to a value in the input vectorx. For example, at the valuexequal to 3, the corresponding cdf valueyis equal to 0.8571.
另外,您可以计算相同的CDF值,而无需创建概率分发对象。使用cdf
function, and specify a Poisson distribution using the same value for the rate parameter,
.
y2 = cdf(“泊松”,x,lambda)
y2 =1×50.1353 0.4060 0.6767 0.8571 0.9473
CDF值与使用概率分布对象计算的值相同。
Plot Standard Normal Distribution cdf
创建标准的正态分布对象。
PD = Makedist('Normal')
pd = NormalDistribution Normal distribution mu = 0 sigma = 1
Specify thex
values and compute the cdf.
x = -3:.1:3; p = cdf(pd,x);
Plot the cdf of the standard normal distribution.
plot(x,p)
情节伽马分布CDF
创建三个伽马分配对象。第一个使用默认参数值。第二个指定a = 1
andb = 2
. The third specifiesa = 2
andb = 1
.
pd_gamma = makedist('Gamma')
pd_gamma = GammaDistribution Gamma distribution a = 1 b = 1
pd_12 = makedist('Gamma','a',1,'b',2)
pd_12 = GammaDistribution Gamma distribution a = 1 b = 2
pd_21 = makedist('Gamma','a',2,'b',1)
pd_21 = GammaDistribution Gamma distribution a = 2 b = 1
Specify thex
values and compute the cdf for each distribution.
x = 0:.1:5;cdf_gamma = cdf(pd_gamma,x);CDF_12 = CDF(PD_12,X);CDF_21 = CDF(PD_21,X);
Create a plot to visualize how the cdf of the gamma distribution changes when you specify different values for the shape parametersa
andb
.
figure; J = plot(x,cdf_gamma); holdon;k =图(x,cdf_12,'r-'); L = plot(x,cdf_21,'k-.'); set(J,'行宽',2);set(k,'行宽',2);传奇([J k l],'a = 1, b = 1','a = 1, b = 2','a = 2, b = 1','Location','东南'); holdoff;
适合帕累托尾巴分布并计算CDF
Fit Pareto tails to a distribution at cumulative probabilities 0.1 and 0.9.
t = trnd(3,100,1); obj = paretotails(t,0.1,0.9); [p,q] = boundary(obj)
p =2×10.1000 0.9000
q =2×1-1.8487 2.0766
Compute the cdf at the values inq
.
cdf(obj,q)
ans =2×10.1000 0.9000
Input Arguments
name
—Probability distribution name
character vector or string scalar of probability distribution name
Probability distribution name, specified as one of the probability distribution names in this table.
name |
Distribution | Input ParameterA |
Input ParameterB |
Input ParameterC |
Input ParameterD |
---|---|---|---|---|---|
'Beta' |
Beta Distribution | afirst shape parameter | bsecond shape parameter | N/A | N/A |
'Binomial' |
Binomial Distribution | nnumber of trials | p每个试验成功的概率 | N/A | N/A |
'Birnbaumsaunders' |
Birnbaum-Saunders Distribution | βscale parameter | γshape parameter | N/A | N/A |
'Burr' |
Burr型XII分布 | αscale parameter | cfirst shape parameter | ksecond shape parameter | N/A |
'Chisquare' or'chi2' |
Chi-Square Distribution | νdegrees of freedom | N/A | N/A | N/A |
'Exponential' |
指数分布 | μ意思是 | N/A | N/A | N/A |
'Extreme Value' or'ev' |
Extreme Value Distribution | μlocation parameter | σscale parameter | N/A | N/A |
'F' |
F Distribution | ν1分子自由度 | ν2denominator degrees of freedom | N/A | N/A |
'Gamma' |
Gamma Distribution | ashape parameter | bscale parameter | N/A | N/A |
'Generalized Extreme Value' or'gev' |
广义的极值分布 | kshape parameter | σscale parameter | μlocation parameter | N/A |
'Generalized Pareto' or'gp' |
Generalized Pareto Distribution | ktail index (shape) parameter | σscale parameter | μthreshold (location) parameter | N/A |
'Geometric' |
Geometric Distribution | p概率参数 | N/A | N/A | N/A |
'Half Normal' or'hn' |
半正常分布 | μlocation parameter | σscale parameter | N/A | N/A |
'Hypergeometric' or'hyge' |
Hypergeometric Distribution | m人口的规模 | k人口中所需特征的项目数量 | nnumber of samples drawn | N/A |
'InverseGaussian' |
Inverse Gaussian Distribution | μscale parameter | λshape parameter | N/A | N/A |
'Logistic' |
Logistic Distribution | μ意思是 | σscale parameter | N/A | N/A |
'LogLogistic' |
日志分布 | μ意思是of logarithmic values | σ对数值的比例参数 | N/A | N/A |
'LogNormal' |
Lognormal Distribution | μ意思是of logarithmic values | σ对数值的标准偏差 | N/A | N/A |
'Loguniform' |
徽标分布 | a较低端点(最小值) | bupper endpoint (maximum) | N/A | N/A |
'Nakagami' |
Nakagami Distribution | μshape parameter | ωscale parameter | N/A | N/A |
'Negative Binomial' or'nbin' |
Negative Binomial Distribution | r成功的数量 | pprobability of success in a single trial | N/A | N/A |
“非中心f” or'ncf' |
Noncentral F Distribution | ν1分子自由度 | ν2denominator degrees of freedom | δnoncentrality parameter | N/A |
'Noncentral t' or'nct' |
Noncentral t Distribution | νdegrees of freedom | δnoncentrality parameter | N/A | N/A |
'Noncentral Chi-square' or'ncx2' |
非中心卡方分布 | νdegrees of freedom | δnoncentrality parameter | N/A | N/A |
'Normal' |
Normal Distribution | μ意思是 | σstandard deviation | N/A | N/A |
“泊松” |
Poisson Distribution | λ意思是 | N/A | N/A | N/A |
'瑞利' |
Rayleigh Distribution | bscale parameter | N/A | N/A | N/A |
'Rician' |
Rician Distribution | snoncentrality parameter | σscale parameter | N/A | N/A |
'稳定的' |
Stable Distribution | αfirst shape parameter | βsecond shape parameter | γscale parameter | δlocation parameter |
'T' |
学生的t分布 | νdegrees of freedom | N/A | N/A | N/A |
'tLocationScale' |
t Location-Scale Distribution | μlocation parameter | σscale parameter | νshape parameter | N/A |
'Uniform' |
Uniform Distribution (Continuous) | a较低端点(最小值) | bupper endpoint (maximum) | N/A | N/A |
'Discrete Uniform' or'unid' |
Uniform Distribution (Discrete) | n最大可观察值 | N/A | N/A | N/A |
'weibull' or'wbl' |
Weibull Distribution | ascale parameter | bshape parameter | N/A | N/A |
例子:'Normal'
x
—价值评估提供
scalar value|array of scalar values
评估CDF的值,指定为标量值或标量值数组。
If one or more of the input argumentsx
,A
,B
,C
, andD
are arrays, then the array sizes must be the same. In this case,cdf
expands each scalar input into a constant array of the same size as the array inputs. Seename
for the definitions ofA
,B
,C
, andD
对于每个分布。
例子:[0.1,0.25,0.5,0.75,0.9]
数据类型:single
|双倍的
A
—第一个概率分布参数
scalar value|array of scalar values
第一个概率分布参数, specified as a scalar value or an array of scalar values.
If one or more of the input argumentsx
,A
,B
,C
, andD
are arrays, then the array sizes must be the same. In this case,cdf
expands each scalar input into a constant array of the same size as the array inputs. Seename
for the definitions ofA
,B
,C
, andD
对于每个分布。
数据类型:single
|双倍的
B
—第二概率分布参数
scalar value|array of scalar values
第二概率分布参数, specified as a scalar value or an array of scalar values.
If one or more of the input argumentsx
,A
,B
,C
, andD
are arrays, then the array sizes must be the same. In this case,cdf
expands each scalar input into a constant array of the same size as the array inputs. Seename
for the definitions ofA
,B
,C
, andD
对于每个分布。
数据类型:single
|双倍的
C
—Third probability distribution parameter
scalar value|array of scalar values
D
—第四概率分布参数
scalar value|array of scalar values
第四概率分布参数, specified as a scalar value or an array of scalar values.
If one or more of the input argumentsx
,A
,B
,C
, andD
are arrays, then the array sizes must be the same. In this case,cdf
expands each scalar input into a constant array of the same size as the array inputs. Seename
for the definitions ofA
,B
,C
, andD
对于每个分布。
数据类型:single
|双倍的
pd
—Probability distribution
probability distribution object
概率分布,指定为该表中的概率分布对象之一。
Distribution Object | Function or App to Create Probability Distribution Object |
---|---|
BetaDistribution |
makedist ,fitdist ,Distribution Fitter |
二项分布 |
makedist ,fitdist ,Distribution Fitter |
BirnbaumSaundersDistribution |
makedist ,fitdist ,Distribution Fitter |
伯德分布 |
makedist ,fitdist ,Distribution Fitter |
ExponentialDistribution |
makedist ,fitdist ,Distribution Fitter |
ExtremeValueDistribution |
makedist ,fitdist ,Distribution Fitter |
伽马分布 |
makedist ,fitdist ,Distribution Fitter |
GeneralizedExtremeValueDistribution |
makedist ,fitdist ,Distribution Fitter |
GeneralizedParetoDistribution |
makedist ,fitdist ,Distribution Fitter |
半normaldistribution |
makedist ,fitdist ,Distribution Fitter |
Inversegaussiandistripution |
makedist ,fitdist ,Distribution Fitter |
kerneldistribution |
fitdist ,Distribution Fitter |
LogisticDistribution |
makedist ,fitdist ,Distribution Fitter |
LogLogisticDistribution |
makedist ,fitdist ,Distribution Fitter |
LognormalDistribution |
makedist ,fitdist ,Distribution Fitter |
loguniformdistripution |
makedist |
MultinomialDistribution |
makedist |
NakagamiDistribution |
makedist ,fitdist ,Distribution Fitter |
NegativeBinomialDistribution |
makedist ,fitdist ,Distribution Fitter |
NormalDistribution |
makedist ,fitdist ,Distribution Fitter |
Piecewise distribution with generalized Pareto distributions in the tails | paretotails |
分段分布 |
makedist |
PoissonDistribution |
makedist ,fitdist ,Distribution Fitter |
雷利德分布 |
makedist ,fitdist ,Distribution Fitter |
RicianDistribution |
makedist ,fitdist ,Distribution Fitter |
StableDistribution |
makedist ,fitdist ,Distribution Fitter |
tLocationScaleDistribution |
makedist ,fitdist ,Distribution Fitter |
三角分裂 |
makedist |
UniformDistribution |
makedist |
weibulldistribution |
makedist ,fitdist ,Distribution Fitter |
Output Arguments
y
— cdf values
scalar value | array of scalar values
Alternative Functionality
cdf
is a generic function that accepts either a distribution by its namename
或概率分配对象pd
. It is faster to use a distribution-specific function, such asnormcdf
对于正态分布和Binocdf
二项分布。的分配ibution-specific functions, seeSupported Distributions.使用Probability Distribution Functionapp to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.
Extended Capabilities
C/C ++代码生成
Generate C and C++ code using MATLAB® Coder™.
用法注释和限制:
The input argument
name
must be a compile-time constant. For example, to use the normal distribution, includecoder.Constant('Normal')
在里面-args
value ofcodegen
(MATLAB编码器).The input argument
pd
can be a fitted probability distribution object for beta, exponential, extreme value, lognormal, normal, and Weibull distributions. Createpd
by fitting a probability distribution to sample data from thefitdist
function. For an example, seeCode Generation for Probability Distribution Objects.
For more information on code generation, seeIntroduction to Code GenerationandGeneral Code Generation Workflow.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
此功能完全支持GPU数组。金宝app有关更多信息,请参阅Run MATLAB Functions on a GPU(Parallel Computing Toolbox).
Version History
matlab命令
You clicked a link that corresponds to this MATLAB command:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。金宝app
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- AméricaLatina(Español)
- Canada(英语)
- United States(英语)
Europe
- 比利时(英语)
- 丹麦(英语)
- Deutschland(Deutsch)
- España(Español)
- Finland(英语)
- France(Français)
- Ireland(英语)
- Italia(Italiano)
- Luxembourg(英语)
- Netherlands(英语)
- Norway(英语)
- Österreich(Deutsch)
- Portugal(英语)
- Sweden(英语)
- Switzerland
- 英国(英语)