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

stable_rand(U, p_value);
% stable_rand.m - sample random numbers from the Alpha-Stable (Levy) Distribution.
%                  See "Computational Statistics", Sec. IV, 1.2, Various Authors, 
%                  online at 'http://www.quantlet.com/mdstat/scripts/csa/html/node235.html'.
%
%  Created by:  Jim Huntley,  03/11/05.
%

function [Y] = stable_rand(U, p_value);

alpha = p_value(1);
sigma = p_value(2);
beta = p_value(3);
mu = p_value(4);

zeta = -beta * tan(0.5*pi*alpha);
W = exprnd(1);

if(alpha == 1)
    xi = 0.5*pi;
    X = ((0.5*pi+beta*U)*tan(U) - beta*log(0.5*pi*W*cos(U)/(0.5*pi+beta*U))) / xi;
    Y = sigma*X + 2*beta*log(sigma)/pi + mu;
elseif(alpha ~= 1)
    xi = atan(-zeta) / alpha;
    X = (1+zeta^2)^(0.5/alpha) * sin(alpha*(U+xi)) * (cos(U-alpha*(U+xi))/W)^((1-alpha)/alpha) ...
        / (cos(U))^(1/alpha);
    Y = sigma*X + mu;
end

return



Contact us