No BSD License  

Highlights from
RANDRAW

4.72917

4.7 | 48 ratings Rate this file 144 Downloads (last 30 days) File Size: 220.28 KB File ID: #7309
image thumbnail

RANDRAW

by Alex Bar-Guy

 

29 Mar 2005 (Updated 06 Aug 2007)

Efficient Random Variates Generator (from over 50 distributions).

| Watch this File

File Information
Description

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

Acknowledgements
This submission has inspired the following:
Compound Poisson simulation
MATLAB release MATLAB 6.5.1 (R13SP1)
Other requirements -
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (56)
27 Apr 2005 Anubhav Swami

Comprehensive random variable generator. Excellent work.

15 May 2005 Feng Sun

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

17 May 2005 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
--------------------------------------
                    
 

26 Jul 2005 dmirty larin

Great and very useful work!

01 Sep 2005 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.

06 Oct 2005 Omer Kravi

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

17 Nov 2005 Rv Le Borgne

Very, very useful!!!
Thanks

30 Nov 2005 srikanth vadde  
09 Dec 2005 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'});

19 Dec 2005 Andreas Wiik

Great worl, thanks for sharing this useful script.

17 Mar 2006 Maria Afonso

Thanks for sharing it with us!

22 May 2006 Tim Brown

Absolutely Fantastic - you are a star!

15 Jun 2006 Valentin Boca

Excellent

30 Jun 2006 Jenny Brown

prevent me from switching to SAS.

13 Aug 2006 Jaime Jaime

very useful.Thanks!

24 Aug 2006 Anyß yamoun

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

14 Sep 2006 tien le

thanks

01 Oct 2006 Peter Nave

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

29 Nov 2006 Yanwei Wang

thanks a lot for your excellent work!

26 Dec 2006 Xudong Wang

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

13 Feb 2007 Andre Crawford

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

10 Mar 2007 Rashmi S.  
16 Mar 2007 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.

27 Mar 2007 Daniel Strezov

It works excellent for me :)

06 Apr 2007 on muk

random

13 Apr 2007 Aasmund Kvamme

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

18 May 2007 Munsik Park

Thanks

26 Jun 2007 Sunil S

incluing Nakagami-m distribution would have made it perfect

01 Jul 2007 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.

03 Sep 2007 Jack Lee

Great program for various distribution generation.

30 Sep 2007 Seno Jinca  
02 Nov 2007 Kyoto Univ  
30 Nov 2007 Lingzhi Liao

It's a wonderful job

28 Feb 2008 paolo mott

and the multivariate case?

28 Mar 2008 Saaaaa sdfasdf  
01 May 2008 yj won  
31 May 2008 ren sisi  
17 Sep 2008 C Schwalm

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

05 Nov 2008 Mason Yost  
05 Dec 2008 koubaa kamal

this is an excellent work.

17 Apr 2009 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?

15 May 2009 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.

17 May 2009 Palash Ranjan

excellent!!

10 Sep 2009 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?

06 Oct 2009 Erdal Bizkevelci  
15 Nov 2009 Md Mahmudul Hasan

Hmm... really helped a lot.!

23 Jul 2010 Rainer  
27 Aug 2010 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?

11 Oct 2010 TideMan  
21 Oct 2010 Xavier Xavier  
29 Jul 2011 Andreas Papadakis

excellent work

16 Aug 2011 Zack

Excellent

16 Aug 2011 Zack  
09 Sep 2011 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

23 Nov 2011 Wes Devauld  
30 Dec 2011 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)

Please login to add a comment or rating.
Updates
14 Apr 2005

Bug fix: Generation from binomial distribution has worked by 'binomial' usage string, but the help for this distribution has worked by 'binom'

18 May 2005

Bugs fix:
1) Poisson:t instead of ti (lam< 21.4)
2) GIG: support to chi=0 or psi=0 cases
3) Beta: column sampleSize
4) Cauchy: typo in example
5) Chi: typo in example
6) Non-central F: number of input params
7) IG: typo in example

22 Jul 2005

Bug fix:
Typo in GIG distribution generation:
should be 'out' instead of 'x' in lines 1852 and 1858

06 Sep 2005

Bugs fix:
 1) GAMMA distribution:
    -special case for a<1
 2) GIG distribution:
    -typo in help;
    -code adjustment to overcome
     possible computational overflows;
3) CHI SQUARE distribution
    -typo in help

12 Dec 2005

true' and 'false' functions were replased by ones and zeros to support Matlab releases below 6.5

12 Dec 2005

true' and 'false' functions were replased by ones and zeros to support Matlab releases below 6.5

12 Dec 2005

true' and 'false' functions were replased by ones and zeros to support Matlab releases below 6.5

21 Feb 2007

GIG distribution (thanks to Mr. Demetris Lamnisos) bug fix:
Computational exceptions in the reparameterized GIG generation were fixed

06 Aug 2007

New distributions support:
Nakagami and Rician

Tag Activity for this File
Tag Applied By Date/Time
statistics Alex Bar-Guy 22 Oct 2008 07:44:34
probability Alex Bar-Guy 22 Oct 2008 07:44:34
random variable generator Alex Bar-Guy 22 Oct 2008 07:44:34
distribution Alex Bar-Guy 22 Oct 2008 07:44:34
effective Alex Bar-Guy 22 Oct 2008 07:44:34
pseudo Alex Bar-Guy 22 Oct 2008 07:44:34
poisson Alex Bar-Guy 22 Oct 2008 07:44:34
random variable generator Deepak 21 Feb 2009 16:07:46

Contact us at files@mathworks.com