truncate
Truncate probability distribution object
Description
Examples
Create 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 =
NormalDistribution
Normal distribution
mu = 0
sigma = 1
Truncated to the interval [-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 on plot(x,pdf(t,x),'LineStyle','--') legend('Normal','Truncated') hold off

Create 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
Probability distribution, specified as one of the probability distribution objects in the following table.
| Distribution Object | Function or App Used to Create Probability Distribution Object |
|---|---|
BetaDistribution | makedist, fitdist, Distribution Fitter |
BinomialDistribution | makedist, fitdist,
Distribution Fitter |
BirnbaumSaundersDistribution | makedist, fitdist,
Distribution Fitter |
BurrDistribution | makedist, fitdist,
Distribution Fitter |
EmpiricalDistribution | fitdist |
ExponentialDistribution | makedist, fitdist,
Distribution Fitter |
ExtremeValueDistribution | makedist, fitdist,
Distribution Fitter |
GammaDistribution | makedist, fitdist,
Distribution Fitter |
GeneralizedExtremeValueDistribution | makedist, fitdist,
Distribution Fitter |
GeneralizedParetoDistribution | makedist, fitdist,
Distribution Fitter |
HalfNormalDistribution | makedist, fitdist,
Distribution Fitter |
InverseGaussianDistribution | makedist, fitdist,
Distribution Fitter |
KernelDistribution | fitdist, Distribution Fitter |
LogisticDistribution | makedist, fitdist,
Distribution Fitter |
LoglogisticDistribution | makedist, fitdist,
Distribution Fitter |
LognormalDistribution | makedist, fitdist,
Distribution Fitter |
LoguniformDistribution | makedist |
MultinomialDistribution | makedist |
NakagamiDistribution | makedist, fitdist,
Distribution Fitter |
NegativeBinomialDistribution | makedist, fitdist,
Distribution Fitter |
NormalDistribution | makedist, fitdist,
Distribution Fitter |
PearsonDistribution | makedist |
PiecewiseLinearDistribution | makedist |
PoissonDistribution | makedist, fitdist,
Distribution Fitter |
RayleighDistribution | makedist, fitdist,
Distribution Fitter |
RicianDistribution | makedist, fitdist,
Distribution Fitter |
StableDistribution | makedist, fitdist,
Distribution Fitter |
tLocationScaleDistribution | makedist, fitdist,
Distribution Fitter |
TriangularDistribution | makedist |
UniformDistribution | makedist |
WeibullDistribution | makedist, fitdist,
Distribution Fitter |
Lower truncation limit, specified as a scalar value.
Data Types: single | double
Upper truncation limit, specified as a scalar value.
Data Types: single | double
Output Arguments
Truncated distribution, returned as a probability distribution object. The
probability distribution function (pdf) of t is 0
outside the truncation interval. Inside the truncation interval, the pdf of
t is equal to the pdf of pd,
but divided by the probability assigned to that interval by
pd.
The object properties of t are the same as those of
pd with these exceptions:
The
Truncationproperty oftstores the truncation interval.The
IsTruncatedproperty oftis 1.The
InputDataproperty oftis empty. For a fitted distribution object, theInputDataproperty stores the data used for distribution fitting. The truncated distribution object does not store the input data.
Extended Capabilities
Usage notes and limitations:
The input argument
pdcan be a fitted probability distribution object for beta, exponential, extreme value, lognormal, normal, and Weibull distributions. Createpdby fitting a probability distribution to sample data from thefitdistfunction. For an example, see Code Generation for Probability Distribution Objects.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,mean, and so on, calltruncateand one or more of these object functions within a single entry-point function.
For more information on code generation, see Introduction to Code Generation and General Code Generation Workflow.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2013a
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)