Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

James Huntley (view profile)

 

generates random variates from over 870 univariate distributions

...
% genormlap_rnd.m - generates 'nsamples' of a Stable random variable.
%   from "Brownian Laplace Motion and Its Use in Financial Modelling", W. J. Reed, U.
%   Victoria, Canada.
%
%   Created by: J. Huntley,  09/25/06
%

function [xhold,xhold2,xhold3,fhold,ghold,jhold,xsort,fsort,gsort,chold,isint] = ...
          genormlap_rnd(userin,p_value,nsamples)

rho = p_value(1);
mu = p_value(2);
sigma = p_value(3);
alpha = p_value(4);
bet = p_value(5);
% Generate 1st Gamma distribution.
userin.distrib = 'gamma'; 
userin.ftype = 4;
userin.p_value = [p_value(1) 0 1];
[xhold2,fhold,ghold,jhold,xsort,fsort,gsort,chold,isint] =  gen_distrib2(userin,1);
% Generate 2nd Gamma distribution.
userin.distrib = 'gamma'; 
userin.ftype = 4;
[xhold3,fhold,ghold,jhold,xsort,fsort,gsort,chold,isint] =  gen_distrib2(userin,2);
% Generate Gaussian distribution.
userin.distrib = 'gaus'; 
userin.ftype = 4;
userin.p_value = [0 1];
[xhold,fhold,ghold,jhold,xsort,fsort,gsort,chold,isint] =  gen_distrib2(userin,0);
xhold = rho.*mu + sigma.*sqrt(rho).*xhold + xhold2./alpha - xhold3./bet;
      
return

Contact us