function CO2_seq_example;

% Prior probabilities
Pleak=0.3;
Pseal=1-Pleak;

% Costs
Cleak=-90;
Cseal=-30;
Csusp=-80;

% Prior value
V_seq=Pleak*Cleak+Pseal*Cseal
PV=max(V_seq,Csusp)

% Posterior value of perfect information
PoV_x=Pleak*max(Csusp,Cleak)+Pseal*max(Csusp,Cseal)
VOPI=PoV_x-PV;

% Likelihood of geophysical experiment
ptestleak_leak=0.9;
ptestseal_leak=1-ptestleak_leak;
ptestleak_seal=0.05;
ptestseal_seal=1-ptestleak_seal;

% Marginal likelihood
ptestleak=ptestleak_leak*Pleak+ptestleak_seal*Pseal
ptestseal=1-ptestleak;

% Cond prob leak given testleak
pleak_testleak=ptestleak_leak*Pleak/ptestleak
pseal_testleak=1-pleak_testleak;
E_testleak=Cleak*pleak_testleak+...
    Cseal*pseal_testleak
% Cond prob leak given testseal
pleak_testseal=ptestseal_leak*Pleak/ptestseal
pseal_testseal=1-pleak_testseal;
E_testseal=Cleak*pleak_testseal+...
    Cseal*pseal_testseal

% Posterior value of geophysical experiment
PoV_y=ptestleak*max(Csusp,E_testleak)+...
    ptestseal*max(Csusp,E_testseal)
VOE=PoV_y-PV;
