www.gusucode.com > stats 源码程序 matlab案例代码 > stats/GenerateRandomNumbersfromaTruncatedDistributionExample.m
%% Generate Random Numbers from a Truncated Distribution %% % Create a standard normal probability distribution object. pd = makedist('Normal') %% % 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) %% % Generate random numbers from the truncated distribution and visualize % with a histogram. r = random(t,10000,1); histogram(r,100)