self ax set_ylabel("probability"self ax set_xlabel("location"self ax set_title("location probability distribution"self ax set_xticks(self hmm statesvals [self loc_filt state_dist[ifor in self hmm statesself bars self ax bar(self hmm statesvalscolor='black'self ax bar_label(self bars,["{ }format( =vfor in vals]padding plt draw( def left(self,event)self loc_filt go("left"self draw_dist(def right(self,event)self loc_filt go("right"self draw_dist(def door(self,event)self loc_filt observe({'door':true}self draw_dist(def nodoor(self,event)self loc_filt observe({'door':false}self draw_dist(def reset(self,event)self loc_filt state_dist { : / for in range( )self draw_dist( sl show_localization(hmm_ posparticle filtering for hmms in this implementation particle is just state if you want to do some form of smoothinga particle should probably be history of states this maintainsparticlesan array of statesweights an array of (non-negativereal numberssuch that weights[iis the weight of particles[iprobhmm py -(continued from display import displayable from probstochsim import resample class hmmparticlefilter(displayable)def __init__(self,hmm,number_particles= )self hmm hmm self particles [sample_one(hmm indistfor in range(number_particles)self weights [ for in range(number_particles) def filter(selfobsseq)"""returns the state distribution following the sequence of observations in obsseq using particle filtering version june