fast binomial random numbers

4 ビュー (過去 30 日間)
Ariel Balter
Ariel Balter 2011 年 8 月 3 日
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

回答 (2 件)

Paulo Silva
Paulo Silva 2011 年 8 月 3 日
Try using the GUI from
deploytool
if you have it installed.
or just
mcc -m binom.m
  5 件のコメント
Paulo Silva
Paulo Silva 2011 年 8 月 3 日
sorry Ariel, I have no experience compiling code with MATLAB
Paulo Silva
Paulo Silva 2011 年 8 月 3 日
The compiler configuration is invoked by
mbuild -setup

サインインしてコメントする。


Walter Roberson
Walter Roberson 2011 年 8 月 3 日
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 件のコメント
Walter Roberson
Walter Roberson 2011 年 8 月 3 日
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
Ariel Balter 2011 年 8 月 3 日
I am running x64, so that may explain the lcc problem. Although, there appears to be a x64 version of lcc.
I tried installing Visual C++ 2010 Express and Microsoft Windows SDK for Windows 7 and .NET Framework 4. I never got asked for an option for x64. Seems like maybe I need visual studio, which is not free.
I appreciate all the help. But, this is getting way beyond the scope of compiling my one line program!
Sounds like the problem starts with my Matlab not having the default compiler.
Oh well.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeC Shared Library Integration についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by