Random numbers from a user defined piecewise polynomial distribution
21 May 2010
RANDPDFS returns pseudorandom values drawn from an arbitrary distribution defined by the pp-form.
% Distributed pseudorandom numbers from an user defined distribution function.
% r=randpdfs(ppdf,n) returns an n-by-n matrix containing pseudorandom values
% drawn from an user defined probability distribution.
% The probability distribution function is defined by using a pp-form
% which can be easily created using spline matlab command.
% The syntax to create random matrix is the same one used by rand command.
% All the information required to compute the random sequence are extracted
% from the pp-form structure, in particular the lowest and the highest
% generated numbers corresponds to the first and last break of the pp form
% randpdfs uses fnint to compute the cumulative distribution function,
% therefore spline toolbox has to be accessible to allow randpdfs working
% Generate values from an arbitraty distribution on the interval [0 2*pi]
clf; hold on
%% See also
% rand, spline, fnint