fast binomial random numbers
Mostra commenti meno recenti
I hate to ask this, because I'm asking someone to do my work for me. Could someone help me write a fast binomial random number generator?
I have written this:
function X = binom(N,p)
X = sum(rand(1,N)<p);
end
which is about 3x faster than the built-in vectorized version.
I would like to write a compiled c version, but I basically know nothing about c.
Thanks
Risposte (2)
Paulo Silva
il 3 Ago 2011
Try using the GUI from
deploytool
if you have it installed.
or just
mcc -m binom.m
5 Commenti
Ariel Balter
il 3 Ago 2011
Paulo Silva
il 3 Ago 2011
I think you have to change your code before compiling, change it to this
function binom(N,p)
sum(rand(1,N)<p)
end
Compiled functions can't have outputs besides the ones like you have at MATLAB command line (notice the absence of the ; on the second line) and commands link the disp and fprintf. You must capture the outputs of the functions, unix style (>).
Ariel Balter
il 3 Ago 2011
Paulo Silva
il 3 Ago 2011
sorry Ariel, I have no experience compiling code with MATLAB
Paulo Silva
il 3 Ago 2011
The compiler configuration is invoked by
mbuild -setup
Walter Roberson
il 3 Ago 2011
0 voti
If you cannot get MATLAB to see lcc win32, then you may be using the 64 bit version of MATLAB. See here for the 2011a Windows 64 list. Please note that there are two pieces of software to install for Windows 64: be sure to read the notes!
3 Commenti
Ariel Balter
il 3 Ago 2011
Walter Roberson
il 3 Ago 2011
I did say to read the notes. The link I posted tells you specifically what else you have to install. See in particular notes #1 and #3.
Ariel Balter
il 3 Ago 2011
Categorie
Scopri di più su Package MATLAB Functions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!