www.gusucode.com > stats 源码程序 matlab案例代码 > stats/FitAHalfNormalDistributionObjectExample.m
%% Fit a Half-Normal Distribution Object %% % Generate 100 random numbers from a standard normal distribution and % compute their absolute value. rng default % For reproducibility x = abs(random(makedist('Normal'),100,1)); %% % Fit a half-normal distribution object to the sample data. pd = fitdist(x,'HalfNormal') %% % Calculate the mean of the fitted half-normal distribution using the % probability distribution object. m = mean(pd) %% % Calculate the mean of the half-normal distribution by substituting the % fitted |mu| and |sigma| parameter values into the formula % % $$mean = \mu + \sigma \sqrt {\frac{2}{\pi }}. $$ mcalc = pd.mu + pd.sigma*(sqrt(2/pi))