官术网_书友最值得收藏!

Absorbing states

State i is said to be an absorbing state if it is impossible for a system to leave that state once it reaches it. For a state to be an absorbing state, the probability of staying in the same state should be 1, and all the other probabilities should be 0:

In a Markov chain, if all the states are absorbing, then we call it an absorbing Markov chain:

Figure 1.7: An example showing an absorbing state C, since the probability of transitioning from state C to C is 1

Again, we can add a very simple method to check for absorbing states in our MarkovChain class:

def is_absorbing(self, state):
"""
Checks if the given state is absorbing.

Parameters
----------
state: str
The state for which we need to check whether it's absorbing
or not.
"""
state_index = self.index_dict[state]
if self.transition_matrix[state_index, state_index]

We can again check whether our state in the example is absorbing by creating a Markov chain and using the is_absorbing method:

>>> absorbing_matrix = [[0, 1, 0],
[0.5, 0, 0.5],
[0, 0, 1]]
>>> absorbing_chain = MarkovChain(transition_matrix=absorbing_matrix,
states=['A', 'B', 'C'])
>>> absorbing_chain.is_absorbing('A')
False
>>> absorbing_chain.is_absorbing('C')
True
主站蜘蛛池模板: 梅河口市| 西乌珠穆沁旗| 旬阳县| 防城港市| 普格县| 乌兰浩特市| 湘潭市| 苍山县| 潜山县| 永安市| 涟源市| 乳山市| 固阳县| 南京市| 临潭县| 湘阴县| 饶阳县| 朝阳市| 博爱县| 土默特左旗| 陈巴尔虎旗| 长沙市| 合作市| 德清县| 钦州市| 富平县| 余姚市| 襄樊市| 通河县| 江山市| 资源县| 宜兰市| 丰县| 彰化市| 嘉义市| 吴堡县| 天峻县| 两当县| 高雄市| 岫岩| 巧家县|