File Exchange

image thumbnail

RANDRAW

version 1.4.0.0 (38.1 KB) by Alex Bar-Guy
Efficient Random Variates Generator (from over 50 distributions).

45 Downloads

Updated 06 Mar 2013

View Version History

View License

RANDRAW

EFFICIENT RANDOM VARIATES GENERATOR (from over 50 distributions):

Alpha,
Anglit,
Antilognormal,
Arcsin,
Bernoulli,
Bessel,
Beta,
Binomial,
Bradford,
Burr,
Cauchy,
Chi,
Chi-Square (Non-Central),
Chi-Square (Central),
Cobb-Douglas,
Cosine,
Double-Exponential,
Erlang,
Exponential,
Extreme-Value,
F (Central),
F (Non-Central),
Fisher-Tippett,
Fisk,
Frechet,
Furry,
Gamma,
Generalized Inverse Gaussian,
Generalized Hyperbolic,
Geometric,
Gompertz,
Gumbel,
Half-Cosine,
Hyperbolic Secant,
Hypergeometric,
Inverse Gaussian,
Laplace,
Logistic,
Lognormal,
Lomax,
Lorentz,
Maxwell,
Nakagami,
Negative Binomial,
Normal,
Normal-Inverse-Gaussian (NIG),
Pareto,
Pareto2,
Pascal,
Planck,
Poisson,
Quadratic,
Rademacher,
Rayleigh,
Rice,
Semicircle,
Skellam,
Student's-t,
Triangular,
Truncated Normal,
Tukey-Lambda,
U-shape,
Uniform (continuous),
Von Mises,
Wald,
Weibull,
Wigner Semicircle,
Yule,
Zeta,
Zipf

Cite As

Alex Bar-Guy (2021). RANDRAW (https://www.mathworks.com/matlabcentral/fileexchange/7309-randraw), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (84)

Fernando Zigunov

Solved my Maxwell-Boltzmann issues!

Selim Sahin

great job and very comprehensive work. thanks for sharing!

Ahmed Awad

Omar Aqel

DC

Chinmayi Gudi

savvasgk

Dangxing Chen

MANEESH KUMAR

Pablo Nanez

Luis Perez

Really usefull to generate aleatory number with a lognormal distribution.

Jianqiao Hao

Really impressive!...Thank you!!!

Jose Bastidas

Excelent!! thank you

jabbar Hussien

Extensive work! Thank you.

jmlarson

There appears to be an issue with the beta distribution:

>> histogram(randraw('beta',[1, 2],1e5));

has a very different appearance than it should:

https://www.wolframalpha.com/input/?i=beta+distribution+a%3D1+b+%3D2

seongjin

Extensive work! Thank you!

Nuno Jorge

Abdulaziz

how can I get doc of Generalized Inverse Gaussian
I would see the density. I typed doc randraw(Generalized Inverse Gaussian) but no thing appear.

Nima

You saved me!!! many thanks!

Long Vo

Thank you very much !

Zhenmao Wan

Nicolas

Gorgeous. Many Thanks

Pete

Impressive. Many thanks

Peter Nave

Extremely useful!

Katha

very good work. thank you for sharing with us.

I have a question:
Who could I plot a diagram like this one you show?

Dylan Muir

Ali montazeri

Great help. Thank you very much for the neat code.

Philipp Andres

Burr Dist: pdf should be:
pdf(y) = c*d * y.^(-c-1) .* (1+y.^c).^(-d-1)
(minus sign in front of power of c)

Wes Devauld

Mohammad Al-Jarrah

Dear Sir, thank you for your code. I am interesting in alpha-mu distribution. Can you help me to generate this this random variable according to this distribution.

maaljarrah08@eng.just.edu.jo

Zack

Zack

Excellent

Andreas Papadakis

excellent work

Xavier Xavier

TideMan

Radi Hristov

Using - 'randraw('bessel', [2 0.9], [1 1e5])' I get an error message:
??? Attempted to access EE(7.46288e+008); index out of bounds because numel(EE)=1.

Error in ==> randraw>randFrom5Tbls at 4373
out(ii) = EE(floor(jj(ii)-t4) + 1);

Error in ==> randraw at 807
out = randFrom5Tbls( P, offset, sampleSize);

Error in ==> DG_IS_gamrnd_BS_Probe at 100
n0 = randraw('bessel', [v z], 1);

What is the Problem with the Bessel Generator?

Rainer

Md Mahmudul Hasan

Hmm... really helped a lot.!

Erdal Bizkevelci

Dominic Vella

Generally very useful. Agree that this ought to be standard in Matlab w/o toolboxes.

However, there seems to be a bug in 'beta'. When I have a=1, b>1 I get a kink in the cdf at x=0.5 and it does not follow betainc as expected.

As soon as I have a>1, even a=1.000001, this kink goes away and the cdf matches betainc perfectly. Any ideas what's going on?

Palash Ranjan

excellent!!

Peter Harris

Thanks, this is very useful.
A minor bug in the beta distribution code - the last line in the case statement is
reshape( out, SampleSizeIn );
but it needs
out = reshape( out, SampleSizeIn );
to work.

Arun M

I'm not sure if anyone has pointed it out, but binomial seems to have a bug:
You define switchflag within a if-else clause in line 881, but it needs to be defined outside it, since, after the clause, you write:
Line 935: if switchFlag
Did old versions of Matlab support use of variables outside what's meant to be their scope?

koubaa kamal

this is an excellent work.

Mason Yost

C Schwalm

This is excellent, and is yet another FEX submission that should be part of standard Matlab sans toolboxes.

ren sisi

yj won

Saaaaa sdfasdf

paolo mott

and the multivariate case?

Lingzhi Liao

It's a wonderful job

Kyoto Univ

Seno Jinca

Jack Lee

Great program for various distribution generation.

Zhang Jianlong

Your program helps me very much in GIG random generator! thank you! I do a progrom by myself,but its efficiency is poor.

Sunil S

incluing Nakagami-m distribution would have made it perfect

Munsik Park

Thanks

Aasmund Kvamme

Very good, but the help-text keeps rolling off my screen. Perhaps some sort of printable documentation?

on muk

random

Daniel Strezov

It works excellent for me :)

Ged Ridgway

Hi, with regard to Xudong Wang's request for Rician samples, you are welcome to take the (very simple) code from my toolbox and adapt it to randraw.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14237&objectType=FILE

Best,
Ged.

Rashmi S.

Andre Crawford

This code is great! The HELP is also wonderfully organized.

Xudong Wang

If it had included Ricean,Nakagami-m distributions, this program would be perfect.

Yanwei Wang

thanks a lot for your excellent work!

Peter Nave

Many thanks for this truly excellent code. In particular, the organization of HELP is remarkable.

tien le

thanks

Anyß yamoun

Nice work !
Fast operations .
No more needs for many Libraries .

Jaime Jaime

very useful.Thanks!

Jenny Brown

prevent me from switching to SAS.

Valentin Boca

Excellent

Tim Brown

Absolutely Fantastic - you are a star!

Maria Afonso

Thanks for sharing it with us!

Andreas Wiik

Great worl, thanks for sharing this useful script.

Subramaniam Lakshmanan

y = randraw('uniform', [2, 3], 1, 1e5);

I am getting the following error message if i execute the above statement. But if i am not specifying any parameter a & b, it works fine. Can u help me with it.

??? Undefined function or variable 'true'.

Error in ==> D:\Random\randraw.m (validateParam)
On line 4105 ==> condLogical = true;

Error in ==> D:\Random\randraw.m
On line 3751 ==> validateParam(funcName, 'Uniform', 'uniform', '[a, b]', 'b-a', b-a, {'> 0'});

srikanth vadde

Rv Le Borgne

Very, very useful!!!
Thanks

Omer Kravi

Excellent work!!! Thanks for GIG random variables generator !!!

Earl Lawrence

Most of this program seems pretty good. There's a bit of bug in the gamma code. The reference they cite has a different algorithm for alpha < 1 which is omitted in the code causing trouble, particularly if try and set alpha = 1/3.

dmirty larin

Great and very useful work!

c m

If I had confidence in the program it would be great.

I tried the program with poisson distribution help, i.e. randraw( 'po') but it produced an error message. See below.

Maybe the problem is similar to the binomial
distribution problem noted in the 4/14/05
change.

This is a great piece of work, but unless
there is confidence in the accuracy of the
program it is not very useful.

Here is the problem I encountered.
--------------------------------------
Input:
randraw( 'po')

The output is an error:
??? if h<=1 &&
Missing variable or function.
Syntax error...
On line 1799
--------------------------------------

Feng Sun

Great work! Thank you very much for sharing this with us!

Anubhav Swami

Comprehensive random variable generator. Excellent work.

MATLAB Release Compatibility
Created with R13SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!