octave code for PGMs