Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

 

generates random variates from over 870 univariate distributions

...
% linnik_rnd.m - generates 'nsamples' of a Linnik random variable.
% from "Random Variate Generation in One Line of Code", L. Devroye.
%
%   Created by: J. Huntley,  09/25/06
%

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

a = p_value(1);
userin.distrib = 'exp'; 
userin.ftype = 4;
userin.p_value = [1];
[xhold,fhold,ghold,jhold,xsort,fsort,gsort,chold,isint] =  gen_distrib2(userin,0);
SE = sign(rand(1,nsamples)-0.5) .* xhold;
U = rand(1,nsamples);
xhold = SE ./ (sin(0.5.*pi.*a).*tan(0.5.*pi.*(1-a.*U))-cos(0.5.*pi.*a)).^(1/a);
      
return

Contact us