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

create_partitions.m
% create_partitions.m - tests for solutions to a Diophantine Equation and writes
%               partitions to sequentialy-numbered .mat files.
%
%   Created by: J. Huntley,  03/23/09.
%

outfilename = 'xxx';
xmin = 1;
xmax = 50;
x = xmin:xmax;

%Create and write partition files.
for jx = xmin:xmax
    % Find all Partitions of 'x'. Returned in cell array, "L".
    [L, callmax, a_new_hold, mult_new_hold] = partition(jx);
    LL{jx} = L;
    pname = [outfilename num2str(jx)]
    save(pname, 'LL')
    clear LL L callmax a_new_hold mult_new_hold;
end

%while(0)
% Read and Print partition and frequency files (Diophantine solutions).
for jx = xmin:xmax
    % Load Partitions from cell array, "L", into array 'p'.
    pname = [outfilename num2str(jx)]
    load(pname, 'LL')
    L = LL{jx};
    sL = size(L,2)
    for js = 1:sL
        s = size(L{1,js},2);
        p(js,1:s) = int8(L{1,js});
    end

    p

    % Construct occurances of each value in each partition in array, 'd'.
    % Array 'd' contains the solutions to the Diophantine Equation.
    spc = size(p,2)
    spr = size(p,1)
    for jr = 1:spr
        for jc = 1:spc
            d(jr,jc) = int8(size(find(p(jr,1:spc) == jc),2));     
        end
    end

    d
end
%end

    

Contact us