马尔科夫链模型状态转移矩阵

import numpy as np
matrix = np.matrix([[0.9,0.075,0.025],[0.15,0.8,0.05],[0.25,0.25,0.5]], dtype=float)
vector1 = np.matrix([[0.3,0.4,0.3]], dtype=float)
for i in range(100):
    vector1 = vector1*matrix
    print ("Current round:" , i+1)
    print (vector1)

Current round: 1
[[0.405  0.4175 0.1775]]
Current round: 2
[[0.4715  0.40875 0.11975]]
Current round: 3
[[0.5156 0.3923 0.0921]]
Current round: 4
[[0.54591  0.375535 0.078555]]
Current round: 5
[[0.567288 0.36101  0.071702]]
Current round: 6
[[0.5826362 0.3492801 0.0680837]]
Current round: 7
[[0.59378552 0.34014272 0.06607176]]
Current round: 8
[[0.60194632 0.33316603 0.06488765]]
Current round: 9
[[0.6079485  0.32790071 0.06415079]]
Current round: 10
[[0.61237646 0.3239544  0.06366914]]
Current round: 11
[[0.61564926 0.32100904 0.0633417 ]]
Current round: 12
[[0.61807111 0.31881635 0.06311253]]
Current round: 13
[[0.61986459 0.31718655 0.06294886]]
Current round: 14
[[0.62119333 0.3159763  0.06283037]]
Current round: 15
[[0.62217803 0.31507813 0.06274383]]
Current round: 16
[[0.62290791 0.31441182 0.06268027]]
Current round: 17
[[0.62344896 0.31391762 0.06263343]]
Current round: 18
[[0.62385006 0.31355112 0.06259882]]
Current round: 19
[[0.62414743 0.31327936 0.06257322]]
Current round: 20
[[0.62436789 0.31307785 0.06255426]]
Current round: 21
[[0.62453135 0.31292843 0.06254022]]
Current round: 22
[[0.62465253 0.31281765 0.06252982]]
Current round: 23
[[0.62474238 0.31273552 0.0625221 ]]
Current round: 24
[[0.624809   0.31267462 0.06251639]]
Current round: 25
[[0.62485839 0.31262947 0.06251215]]
Current round: 26
[[0.624895   0.31259599 0.06250901]]
Current round: 27
[[0.62492215 0.31257117 0.06250668]]
Current round: 28
[[0.62494228 0.31255277 0.06250495]]
Current round: 29
[[0.62495721 0.31253912 0.06250367]]
Current round: 30
[[0.62496827 0.31252901 0.06250272]]
Current round: 31
[[0.62497648 0.31252151 0.06250202]]
Current round: 32
[[0.62498256 0.31251594 0.0625015 ]]
Current round: 33
[[0.62498707 0.31251182 0.06250111]]
Current round: 34
[[0.62499041 0.31250876 0.06250082]]
Current round: 35
[[0.62499289 0.3125065  0.06250061]]
Current round: 36
[[0.62499473 0.31250482 0.06250045]]
Current round: 37
[[0.62499609 0.31250357 0.06250034]]
Current round: 38
[[0.6249971  0.31250265 0.06250025]]
Current round: 39
[[0.62499785 0.31250196 0.06250018]]
Current round: 40
[[0.62499841 0.31250146 0.06250014]]
Current round: 41
[[0.62499882 0.31250108 0.0625001 ]]
Current round: 42
[[0.62499912 0.3125008  0.06250008]]
Current round: 43
[[0.62499935 0.31250059 0.06250006]]
Current round: 44
[[0.62499952 0.31250044 0.06250004]]
Current round: 45
[[0.62499964 0.31250033 0.06250003]]
Current round: 46
[[0.62499974 0.31250024 0.06250002]]
Current round: 47
[[0.6249998  0.31250018 0.06250002]]
Current round: 48
[[0.62499985 0.31250013 0.06250001]]
Current round: 49
[[0.62499989 0.3125001  0.06250001]]
Current round: 50
[[0.62499992 0.31250007 0.06250001]]
Current round: 51
[[0.62499994 0.31250005 0.06250001]]
Current round: 52
[[0.62499996 0.31250004 0.0625    ]]
Current round: 53
[[0.62499997 0.31250003 0.0625    ]]
Current round: 54
[[0.62499998 0.31250002 0.0625    ]]
Current round: 55
[[0.62499998 0.31250002 0.0625    ]]
Current round: 56
[[0.62499999 0.31250001 0.0625    ]]
Current round: 57
[[0.62499999 0.31250001 0.0625    ]]
Current round: 58
[[0.62499999 0.31250001 0.0625    ]]
Current round: 59
[[0.62499999 0.3125     0.0625    ]]
Current round: 60
[[0.625  0.3125 0.0625]]
Current round: 61
[[0.625  0.3125 0.0625]]
Current round: 62
[[0.625  0.3125 0.0625]]
Current round: 63
[[0.625  0.3125 0.0625]]
Current round: 64
[[0.625  0.3125 0.0625]]
Current round: 65
[[0.625  0.3125 0.0625]]
Current round: 66
[[0.625  0.3125 0.0625]]
Current round: 67
[[0.625  0.3125 0.0625]]
Current round: 68
[[0.625  0.3125 0.0625]]
Current round: 69
[[0.625  0.3125 0.0625]]
Current round: 70
[[0.625  0.3125 0.0625]]
Current round: 71
[[0.625  0.3125 0.0625]]
Current round: 72
[[0.625  0.3125 0.0625]]
Current round: 73
[[0.625  0.3125 0.0625]]
Current round: 74
[[0.625  0.3125 0.0625]]
Current round: 75
[[0.625  0.3125 0.0625]]
Current round: 76
[[0.625  0.3125 0.0625]]
Current round: 77
[[0.625  0.3125 0.0625]]
Current round: 78
[[0.625  0.3125 0.0625]]
Current round: 79
[[0.625  0.3125 0.0625]]
Current round: 80
[[0.625  0.3125 0.0625]]
Current round: 81
[[0.625  0.3125 0.0625]]
Current round: 82
[[0.625  0.3125 0.0625]]
Current round: 83
[[0.625  0.3125 0.0625]]
Current round: 84
[[0.625  0.3125 0.0625]]
Current round: 85
[[0.625  0.3125 0.0625]]
Current round: 86
[[0.625  0.3125 0.0625]]
Current round: 87
[[0.625  0.3125 0.0625]]
Current round: 88
[[0.625  0.3125 0.0625]]
Current round: 89
[[0.625  0.3125 0.0625]]
Current round: 90
[[0.625  0.3125 0.0625]]
Current round: 91
[[0.625  0.3125 0.0625]]
Current round: 92
[[0.625  0.3125 0.0625]]
Current round: 93
[[0.625  0.3125 0.0625]]
Current round: 94
[[0.625  0.3125 0.0625]]
Current round: 95
[[0.625  0.3125 0.0625]]
Current round: 96
[[0.625  0.3125 0.0625]]
Current round: 97
[[0.625  0.3125 0.0625]]
Current round: 98
[[0.625  0.3125 0.0625]]
Current round: 99
[[0.625  0.3125 0.0625]]
Current round: 100
[[0.625  0.3125 0.0625]]

你可能感兴趣的:(矩阵,线性代数,机器学习)