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

disnorm_pdf(n, nmin, sigma, nmax)
% disnorm_pdf.m  is the Discrete Normal Probability Density.
%   See "Generating NonUniform Random Variables", Chap. 3, L. Devroye.
%
%  Created by Jim Huntley,  09/11/06
%


function [pdf] = disnorm_pdf(n, nmin, sigma, nmax)

%persistent sumpdf

%if(isempty(sumpdf))
    sumpdf = 0;
    for jn = nmin:nmax
        sumpdf = sumpdf + exp(-((abs(jn)+1/2)^2/(2*sigma^2)));
    end
%end
        
pdf = exp(-((abs(n)+1/2)^2/(2*sigma^2))) / sumpdf;

return

Contact us