www.gusucode.com > stats 源码程序 matlab案例代码 > stats/TruncateaProbabilityDistributionExample.m

    %% Truncate a Probability Distribution  

%% 
% Create a standard normal probability distribution object. 
pd = makedist('Normal')  

%% 
% Truncate the distribution to have a lower limit of -2 and an upper limit
% of 2. 
t = truncate(pd,-2,2)  

%% 
% Plot the pdf of the original and truncated distributions for a visual
% comparison. 
x = -3:.1:3;
figure;
plot(x,pdf(pd,x),'Color','red','LineWidth',2)
hold on;
plot(x,pdf(t,x),'Color','blue','LineWidth',2,'LineStyle',':')
legend({'Normal','Truncated'},'Location','NE')
hold off;