truncate
Truncate probability distribution object
Syntax
描述
Examples
截断概率分布
创造a standard normal probability distribution object.
PD= makedist('Normal')
PD= NormalDistribution Normal distribution mu = 0 sigma = 1
Truncate the distribution to have a lower limit of -2 and an upper limit of 2.
t = truncate(pd,-2,2)
t =正常分布分布mu = 0 sigma = 1截断为间隔[-2,2]
Plot the pdf of the original and truncated distributions for a visual comparison.
x = linspace(-3,3,1000); figure plot(x,pdf(pd,x)) hold上plot(x,pdf(t,x),'linestyle','--') legend('Normal','Truncated') 抓住离开
从截断的分布中生成随机数
创造a standard normal probability distribution object.
PD= makedist('Normal')
PD= NormalDistribution Normal distribution mu = 0 sigma = 1
Truncate the distribution by restricting it to positive values. Set the lower limit to 0 and the upper limit to infinity.
t = truncate(pd,0,inf)
t = NormalDistribution Normal distribution mu = 0 sigma = 1 Truncated to the interval [0, Inf]
Generate random numbers from the truncated distribution and visualize with a histogram.
r = random(t,10000,1); histogram(r,100)
Input Arguments
PD
—Probability distribution
概率分配对象
Probability distribution, specified as a probability distribution object.
创造a probability distribution object with specified parameter values usingmakedist
.
Alternatively, for a fittable distribution, create a probability distribution object by fitting it to data usingfitdist
或者Distribution Fitter应用程序。
lower
—Lower truncation limit
scalar value
较低的截断极限,指定为标量值。
Data Types:single
|double
upper
—Upper truncation limit
scalar value
上部截断极限,指定为标量值。
Data Types:single
|double
Output Arguments
t
— Truncated distribution
概率分配对象
Truncated distribution, returned as a probability distribution object. The probability distribution function (pdf) oft
is 0 outside the truncation interval. Inside the truncation interval, the pdf oft
is equal to the pdf ofPD
, but divided by the probability assigned to that interval byPD
.
The object properties oft
与那些相同PD
with these exceptions:
The
Truncation
property oft
stores the truncation interval.The
IsTruncated
property oft
is 1.The
输入数据
property oft
是空的。对于拟合的分销对象,输入数据
属性存储用于分发拟合的数据。截断的分布对象不会存储输入数据。
Extended Capabilities
C/C++ Code Generation
使用MATLAB®CODER™生成C和C ++代码。
Usage notes and limitations:
The input argument
PD
可以是beta,指数,极值,lognormal,andar和weibull分布的合适概率分布对象。创造PD
by fitting a probability distribution to sample data from thefitdist
function. For an example, see代码生成概率分布对象.A truncated probability distribution object cannot be an input argument of an entry-point function. To evaluate a truncated distribution using object functions such as
cdf
,PDf
,意思是
, and so on, calltruncate
和上e or more of these object functions within a single entry-point function.
For more information on code generation, seeIntroduction to Code Generation和General Code Generation Workflow.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择一个网站
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:.
您还可以从以下列表中选择一个网站:
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.
美洲
- AméricaLatina(Español)
- Canada(English)
- 美国(English)
欧洲
- Belgium(English)
- 丹麦(English)
- Deutschland(德意志)
- españa(Español)
- Finland(English)
- 法国(Français)
- 爱尔兰(English)
- 意大利(Italiano)
- Luxembourg(English)
- Netherlands(English)
- 挪威(English)
- Österreich(德意志)
- Portugal(English)
- Sweden(English)
- 瑞士
- 英国(English)