The HMM library consists of two main class objects,
Trap
and another class derived from it called
Traps
. The first one has three mandatory arguments, the name of the defect, its step height and the number of emitting states. Depending on the number of states, keyword arguments for the forward and backward rates for all states have to be provided in Hz. States without emission (i.e. thermal states, see Section 5.2.2) is defined with the method
addTiedState
. Additionally, limits for and the rates, the initial voltage offset as well as a list with the corresponding charge of each state can be set optionally.
The
Traps
class takes a list of traps, from which it calculates the combined system using the data provided by the
Trap
objects in the list. The probably most important method used to train the model is
fit
, which takes a sequence of observations and uses a modified Baum-Welch algorithm to fit the individual defects independently of each other. A simplified flow chart of the training algorithm is given in Figure A.1.
It should be noted that the implementations of the Viterbi algorithm, the forward and backward algorithm and some other methods are provided by the pomegranate HMM library [224]. One example of the training of a two-defect system shows the simple usage of the provided classes:
from hmm import Trap,Traps # reading and processing of measurement data < ... > two = TwoState( name = ' twostate ' , dVth =5.0, dVthRange =(4., 6.) , k12 =1 e3 , k21 =1 e2 ) four = Trap ( name = ' fourstate ' , nrStates =3, dVth =3.0, charge = [0,1,2], k12 =0.1, k21 =0.5, k23 =10.0, k32 =3.0) # add thermal state to state 2 with tauc =2 s , taue =10 s four . addTiedState (2, 1./2, 1./10) defects = Traps([ two , four ], sigma =0.5) # train the HMM defects . fit ([ data1 , data2 , data3 ], update =1 e -5, iterations =(5, 100) , jobs = threads ) # plot results print defects defects . plot ()