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

kennedy_pdf(x)
% kennedy_pdf.m - evaluates a Kennedy Probability Density.
%   See "Antipersistence in German Stock Returns", K-K Kunze & H.G. Strohe,
%   Stat. Dist No.39, Potsdam U., 2010, 
%   http://opus.kobv.de/ubp/volltexte/2010/4558/pdf/statdisk39.pdf
%
%  Created by Jim Huntley,  08/17/11
%

function [pdf] = kennedy_pdf(x)

pmin = 1e-8;
sx = size(x,2);

for jx = 1:sx
    sumk1 = 0;
    kmax = max(min(1e5,10/(x(jx))^4),100);      %heuristic
    for jk = 1:kmax
        sumk1 = sumk1 + (4*jk^2*x(jx)*(4*jk^2*x(jx)^2 - 1)) / exp(2*jk^2*x(jx)^2) - ...
                        (8*jk^2*x(jx)) / exp(2*jk^2*x(jx)^2);
    end
    pdf(jx) = max(pmin,2 * sumk1);
end

return

Contact us