.. _example_plot_hmm_stock_analysis.py: ========================== Gaussian HMM of stock data ========================== This script shows how to use Gaussian HMM. It uses stock price data, which can be obtained from yahoo finance. For more information on how to get stock prices with matplotlib, please refer to date_demo1.py of matplotlib. .. image:: images/plot_hmm_stock_analysis_1.png :align: center **Script output**:: fitting to HMM and decoding ... done Transition matrix [[ 8.20695481e-01 1.49210626e-01 1.06848405e-05 2.92311123e-02 8.52096403e-04] [ 1.54782952e-01 7.19159285e-01 3.52862394e-03 1.18609440e-01 3.91969886e-03] [ 3.61619978e-18 7.65341124e-17 4.12943280e-01 3.23743560e-01 2.63313161e-01] [ 3.28418752e-02 3.16176778e-01 2.40983000e-02 6.26883047e-01 2.61802797e-15] [ 2.40276247e-03 9.84887416e-09 2.08644593e-02 1.52485897e-16 9.76732768e-01]] means and vars of each hidden state 0th hidden state mean = [ 6.03454775e-03 4.91312189e+07] var = [ 4.53323623e-02 1.09746237e+14] 1th hidden state mean = [ 1.09466697e-02 6.99415803e+07] var = [ 1.10716484e-01 1.52864947e+14] 2th hidden state mean = [ -7.30180124e-01 1.49242939e+08] var = [ 5.51143378e+00 1.02536368e+16] 3th hidden state mean = [ 3.53274375e-02 1.10486838e+08] var = [ 1.76134543e-01 8.81699722e+14] 4th hidden state mean = [ 2.63277015e-02 4.96971622e+07] var = [ 7.92691581e-01 2.50332012e+14] **Python source code:** :download:`plot_hmm_stock_analysis.py ` .. literalinclude:: plot_hmm_stock_analysis.py :lines: 11- **Total running time of the example:** 25.86 seconds