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

rwalkrng_cdf(x, argt)
% rwalkrng_cdf.m - evaluates a Random Walk Range Cumulative Distribution.
%   See "Efficient Estimation od Intraday Volitility: A Method of Moments Approach 
%   Incorporating the Trading Range", R.B. Spurgin & T. Scheeweis, 
%   CISDM Working Paper Series 97-6, 20 June, 1997. 
%
%   Vector form of CDF !!!
%
%  Created by Jim Huntley,  06/13/11
%

function [cdf] = rwalkrng_cdf(x, argt)

kmax = 100;
cmin = 1e-9;

for jx = 1:size(x,2)
    sumk = 0;
    xa = x(jx) / argt;
    for jk = 1:kmax
        k = jk;
        sumk = sumk + (-1)^(k+1) * k * (erfc((k+1)*xa) - 2*erfc(k*xa) + ...
                      erfc((k-1)*xa));
    end
    cdf(jx) = max(cmin,sumk);
end

return

Contact us