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

twdp_pdf(x, sigma, v1, v2)
% twdp_pdf.m - evaluates a Two-Wave Diffuse Power Probability Density.
%   See "New Analytical Models and Probability Density Functions
%   for Fading in Wireless Communications", G. D. Durgin et al., 
%   IEEE Trans. on Comm., Vol. 50, No. 6, June 2002.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  10/13/06
%

function [pdf] = twdp_pdf(x, sigma, v1, v2)

%persistent K delta nt theta f ft first

$if(isempty(first))
    K = 0.5 * (v1^2 + v2^2) / sigma^2;
    delta = 2 * v1 * v2 / (v1^2 + v2^2);
    nt = 1000;
    dt = pi/(nt-1);
    theta = 0:dt:pi;
    ft = delta .* K .* cos(theta);
    f(1:nt) = 0;
    first = 1;
%end

x = x ./ sigma;
sx = size(x,2);
pdf(1:sx) = 0;

for jx = 1:sx
    for jt = 1:nt
        f(jt) = exp(ft(jt)) * besseli(0,x(jx)*sqrt(2*(K-ft(jt))));
    end
    I = simps(f) * dt;
    pdf(jx) = x(jx) * exp(-0.5*x(jx)^2 - K) * I / sigma;    
end 

return

Contact us