Be the first to rate this file! 6 Downloads (last 30 days) File Size: 14.92 KB File ID: #30966
image thumbnail

rand_gamma

by Matthew Roughan

 

04 Apr 2011

Generates Gamma randomc variables.

| Watch this File

File Information
Description

Generate a Gamma random variable
    "Statistical Distributions", Evans, Hastings, Peacock, 2nd Edition,
    Wiley, 1993, p.75-81

INPUTS:
       (N,M) = size of array of random variables to generate
       b = scale parameter > 0
       c = shape parameter > 0

 probability density function (pdf)
    p(x) = (x/b)^(c-1) * exp(-x/b) / (b * gamma(c))

 where gamma(c) is the gamma function (http://en.wikipedia.org/wiki/Gamma_function)

Basic stats of the gamma distribution
       mean = b c
   variance = b^2 c

 generation method comes from
    http://en.wikipedia.org/wiki/Gamma_distribution#Generating_gamma-distributed_random_variables
          notation: theta = b
                    k = c
 the algorithm exploits several properties of the gamma
   (1) Gamma(b,1) ~ Exp(b) (an exponential random variable)
   (2) sum_{i=1}^{n} Gamma(b,c_i) ~ Gamma(b,c) where c=sum_{i=1}^{n} c_i
 plus acceptance-rejectance sampling

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
random Matthew Roughan 05 Apr 2011 10:27:38
statistics Matthew Roughan 05 Apr 2011 10:27:38
simulation Matthew Roughan 05 Apr 2011 10:27:38

Contact us at files@mathworks.com