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

    %% Generate Random Samples Using the Johnson System
% This example shows several different approaches to using the Johnson
% system of flexible distribution families to generate random numbers and
% fit a distribution to sample data.

% Copyright 2015 The MathWorks, Inc.


%%
% Generate random values with longer tails than a standard normal.
rng default;  % For reproducibility
r = johnsrnd([-1.7 -.5 .5 1.7],1000,1);
figure;
qqplot(r);

%%
% Generate random values skewed to the right.
r = johnsrnd([-1.3 -.5 .5 1.7],1000,1);
figure;
qqplot(r);

%%
% Generate random values that match some sample data well in the right-hand
% tail.
load carbig;
qnorm = [.5 1 1.5 2];
q = quantile(Acceleration, normcdf(qnorm));
r = johnsrnd([qnorm;q],1000,1);
[q;quantile(r,normcdf(qnorm))]

%%
% Determine the distribution type and the coefficients.
[r,type,coefs] = johnsrnd([qnorm;q],0)