The code in alarm.m will create CPTs for the alarm network.

Each variable is assigned a number, e.g.,

     HISTORY =  1;   % TRUE=1 FALSE=2 
     LVFAILURE =  6;   % TRUE=1 FALSE=2 

A mapping from variable numbers to their names is in varnames, e.g.,

  varnames{HISTORY} = 'HISTORY';

A CPT is defined using table_factor.m (which was used in hw2)

  vars = [LVFAILURE HISTORY];
  probs = zeros([2 2]);
  probs(1,1) = 0.900000;
  probs(1,2) = 0.100000;
  probs(2,1) = 0.010000;
  probs(2,2) = 0.990000;
  cpt{HISTORY} = table_factor(vars,probs)

This is the conditional probability table P(HISTORY|LVFAILURE), which is
stored in the cell array cpt. The last variable is always the child. In
the above example cpt{HISTORY} should be interpreted as

P(HISTORY = TRUE | LVFAILURE = TRUE) = 0.9
P(HISTORY = FALSE | LVFAILURE = TRUE) = 0.1
P(HISTORY = TRUE | LVFAILURE = FALSE) = 0.01
P(HISTORY = FALSE | LVFAILURE = FALSE) = 0.99 

Note that summing over the last dimension of a cpt should always equal 1.0,
for example:

>> sum(cpt{HISTORY}.table,length(cpt{HISTORY}.vars))

ans =

     1
     1

% PLEASE NOTE that the factors are stored in a cell array, so you should convert them to a normal array in case
% you want to interface with the solution posted for HW2
