# 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:

where is the shape parameter, is the scale parameter and 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')


## 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

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:

The inverse-gamma distribution has the following density:

## 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