Code

Project: jvfeatures

jvtypes.h      jvfeatures.h      chessSeg.cpp      jvtypes.cpp      jvtest.cpp      jvfeatures.cpp     

Project: Other

migrateMailbox.scpt.txt     

Project: Infinite HMM Tutorial

run.m      iHMM_tutorial.zip      HDP_HMM.m      README.txt      ConditionalProbabilityTable.m      HDP.m      HMMProblem.m      HMM.m     

Project: RRT

RRT.h      plot_output.py      RRT.tgz      rrt_test.cpp      RRT.cpp      BidirectionalRRT.cpp      AbstractRRT.cpp     

Project: Box2D_friction_mod

WheelConstraint.h      test_TopDownCar.py      b2FrictionJoint.h      python_friction_joint.patch      test_TopDownFrictionJoint.py      TestEntries.cpp      TopDownCar.h      b2FrictionJoint.cpp      box2d_friction_joint.patch     

Project: Dirichlet Process Mixture Tutorial

EM_GM.m      DP_Demo.m      DPMM.m      DP_Tutorial.zip      DirichletProcess.m      gaussian_EM.m     

Project: Arduino_Code

plot_ardunio_data.sh      Arduino_Code.zip      convert_range2D.py      arduino-serial.c      oscilloscope.sh      oscilloscope.pde      motordriver.pde      helicopter_controller.pde      accelerometer_test.pde      ranger_plane_sweep.pde      clodbuster_controller.pde      pwm_manual.pde      ranger_test.pde      servo_test.pde     

Project: ArduCom

arducom.py      setup.py     

Project: support

geshi.php      Protector.php     

Project: Cogent

CodePane.php      NotesPane.php      PicsPane.php      Cogent.php      PubsTable.php     
Click here to download "resources/code/Infinite HMM Tutorial/ConditionalProbabilityTable.m"

resources/code/Infinite HMM Tutorial/ConditionalProbabilityTable.m

classdef ConditionalProbabilityTable < handle
    % An interface and basic implementation for defining conditional
    % probability tables.
    %
    % The intended application is for use in an HMM, which learns this
    % distrubution using Gibbs sampling.  For these reason, the public
    % interface consists of functions for moving probability mass around
    % (incrementing and decrement), and getting the CPT (presumably to
    % evaluate various likelihoods).
    %
    % Note that the internal representation is just an un-normalized matrix
    % of counters, which is more convenient to work with in our sampler.
    %
    % Jonathan Scholz
    % jkscholz@gatech.edu
    % 11/2/2011
   
    properties(Access=public) % protected
        % The primary data data structure for the CPT - an nXm matrix of
        % counters
        countMtr = [];
    end
   
    methods(Access=public)
        function reset(obj)
            obj.countMtr = [];
        end

        % Add qty probability mass to the jth component of the ith row
        function success = incrementCountMatrix(obj, i, j, qty)
            obj.countMtr(i, j) = obj.countMtr(i, j) + qty;
            success = true;
        end
       
        % Remove qty probability mass from the jth component of the ith row
        function success = decrementCountMatrix(obj, i, j, qty)
            success = false;
            assert(i <= size(obj.countMtr,1) && j <= size(obj.countMtr,2));
            if obj.countMtr(i, j) >= qty
                obj.countMtr(i, j) = obj.countMtr(i, j) - qty;
                success = true;
            end
        end
       
        % Retreive the full count matrix
        function countMtr = getCountMatrix(obj)
            countMtr = obj.countMtr;
        end
       
        % Compute the CPT
        function CPT = getCPT(obj)
            CM = obj.countMtr + 0.03; % pad count matrix to smooth out likelihoods a bit
            rowsums = sum(CM,2);
            CPT = bsxfun(@rdivide, CM, rowsums);
        end
       
        % Set the internal Count Matrix
        function setCountMatrix(obj, countMtr)
            obj.countMtr = countMtr;
        end
    end
end

About me

Pic of me