gammafactory

gammafactory

Construct a gamma distribution structure

Syntax

D = gammafactory()

Description

D = gammafactory() returns a structure representing a gamma distribution.

Distribution Parameters

  • a (positive scalar) : The shape parameter.
  • b (positive scalar) : The scale parameter.

Probability Density Function

The distribution has the following density:

$$ f(x)=\frac{1}{\Gamma(a)b^a} x^{a-1} \exp(-\frac{x}{b}) $$

where $a > 0$ is the shape parameter, $b > 0$ is the scale parameter and $\Gamma$ is the gamma function.

Example

% Construct a gamma distribution
D = gammafactory();
% Plot the PDF for various values of the shape parameter:
data = 0:0.1:10;
f = zeros(4, numel(data));
for a = 1:4
    theta = struct('a', a, 'b', 1);
    f(a,:) = D.pdf(theta, data);
end
plot(data, f)
legend('a=1', 'a=2', 'a=3', 'a=4')

name

See distribution structure common members.

M

See distribution structure common members.

dim

See distribution structure common members.

datadim

See distribution structure common members.

ll

See distribution structure common members.

llvec

See distribution structure common members.

llgrad

See distribution structure common members.

llgraddata

See distribution structure common members.

cdf

See distribution structure common members.

pdf

See distribution structure common members.

sample

See distribution structure common members.

randparam

See distribution structure common members.

init

See distribution structure common members.

estimatedefault

Default estimation function for gamma distribution.

Syntax

theta = D.estimatedefault(data)
theta = D.estimatedefault(data, options)
[theta, D] = D.estimatedefault(...)
[theta, D, info] = D.estimatedefault(...)
[theta, D, info, options] = D.estimatedefault(...)

penalizerparam

See distribution structure common members.

Penalizer Info

The default penalizer is like having a exponential distribution prior on on parameter (a) and inversegamma on (a*b) as explained in the paper: Wiper et al. "Mixtures of Gamma Distributions with application"

The exponential distribution has the following density:

$$ f(x) \propto \lambda \exp(-\lambda x) $$

The inverse-gamma distribution has the following density:

$$ f(x) \propto x^{-\alpha-1} \exp( -\beta / x ) $$

penalizercost

See distribution structure common members.

penalizergrad

See distribution structure common members.

sumparam

See distribution structure common members.

scaleparam

See distribution structure common members.

sumgrad

See distribution structure common members.

scalegrad

See distribution structure common members.

entropy

See distribution structure common members.

kl

See distribution structure common members.

AICc

See distribution structure common members.

BIC

See distribution structure common members.

display

See distribution structure common members.

fixate

Make some parameters fixed

Syntax

newD = D.fixate(paramName, paramValue, ...)

Description

newD = D.fixate(paramName, paramValue, ...) returns the new gamma distribution newD where the specified parameters are fixed so that they won't change in estimation. paramName is the name of the parameter ('a' or 'b') and paramValue is its desired fixed value.

Example

D = gammafactory();
D = D.fixate('a', 2);

unfix

Undo fixate

Syntax

newD = D.unfix(paramName, ...)

Description

newD = D.unfix(paramName, ...) where D is a gamma distribution with fixed parameters, returns the new gamma distribution newD where the specified parameters are unfixed. paramName is the name of the parameter ('a' or 'b').

Example

D = gammafactory();
D = D.fixate('a', 2, 'b', 1);
D = D.unfix('a');

fullparam

Get the full parameter structure, given the variable parameter structure

Syntax

fulltheta = D.fullparam(theta)

Description

fulltheta = D.fullparam(theta) where D is a gamma distribution with fixed parameters, returns the full parameters of the gamma distribution including the fixed parameters. theta is a parameter structure for the distribution D (i.e. excluding the fixed parameters).

Example

D = gammafactory();
D = D.fixate('a', 2);
theta = struct('b', 1);
fulltheta = D.fullparam(theta)
fulltheta =
    b: 1
    a: 2