File Exchange

image thumbnail

Binomial Random Number Generator

version 1.0.0.0 (1.6 KB) by David
Generates Binomial random numbers B(N,p). Works efficiently for large trial sizes, N.

2 Downloads

Updated 08 Jul 2013

View License

The builtin binornd takes N operations to generate a single deviate, which is impossibly slow when N is large. The current code, modelled on the algorithm in Numerical Recipes, works efficiently for all N. Takes as input two vectors of length L, one with the N's and the second with the p's.

Comments and Ratings (2)

Thanks! I got around 1.3x speedup for N = 100ish.

Mike F

Gave me an order-of-magnitude speed up for my task. Thanks!

--Mike

PS. There first line is missing a comment %. After fixing that, ran great.

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags