
% *************************************************************************
%
% FILE: pumpexample.m
%
% Date Created: April 12, 2004
% Author: Mark E. Irwin
%
% Contents: Pump failure example of Gaver and O'Muircheartaigh (1987) as
%           proposed by Gelfand and Smith (1990).  Analysis by Gibbs
%           Sampler.
%
%           p_i | lambda_i ~ Poisson(lambda_i t_i)
%           lambda_i | beta ~ Gamma(alpha, beta)
%           beta | delta, gamma ~ IGamma(gamma, delta)
%
% Revision History
% Date          Name            Changes/Reasons
%
% *************************************************************************
%
% Input:
%
%  None
%
% Output:
%
%   None, but many variables are created
%
% *************************************************************************

% Data

failures = [5; 1; 5; 14; 3; 19; 1; 1; 4; 22];
time = [94.32; 15.72; 62.88; 125.76; 5.24; 31.44; 1.048; 1.048; 2.096; 10.48];
rawrates = failures ./ time;

% Prior

alpha = 1.8;
delta = 1;
gamma = 0.1;

% Sampler Parameters

betastart = mean(rawrates) / alpha; 
% betastart = 0;
niter = 101000;

[lambda, beta] = pumpgibbs(failures, time, alpha, delta, gamma, niter, betastart);
    
    