Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Sat Jul 11 20:21:09 2015
- """
- import random, math, scipy, numpy, tabulate, matplotlib
- from tabulate import tabulate
- def Markov(n, s):
- '''
- n represents the number of states
- s represents the number of time-steps
- '''
- a_11 = random.random()
- a_12 = random.random()
- a_13 = 1 - (a_11 + a_12)
- b_11 = random.random()
- b_12 = random.random()
- b_13 = 1 - (b_11 + b_12)
- c_11 = random.random()
- c_12 = random.random()
- c_13 = 1 - (c_11 + c_12)
- table = [[a_11, a_12, a_13],
- [b_11, b_12, b_13],
- [c_11, c_12, c_13]]
- print tabulate(table)
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
- Reloaded modules: tabulate
- -------- -------- ---------
- 0.327009 0.539087 0.133904
- 0.541266 0.211004 0.24773
- 0.569579 0.392514 0.0379069
- -------- -------- ---------
- runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
- Reloaded modules: tabulate
- -------- -------- ---------
- 0.963362 0.759905 -0.723267
- 0.676055 0.546022 -0.222077
- 0.248199 0.837107 -0.085306
- -------- -------- ---------
- runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
- Reloaded modules: tabulate
- -------- --------- --------
- 0.713195 0.0273135 0.259492
- 0.264634 0.311998 0.423368
- 0.477829 0.250097 0.272074
- -------- --------- --------
- runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
- Reloaded modules: tabulate
- --------- --------- --------
- 0.192538 0.0359414 0.77152
- 0.0820929 0.541748 0.376159
- 0.0801376 0.595351 0.324512
- --------- --------- --------
- runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
- Reloaded modules: tabulate
- -------- --------- ---------
- 0.659396 0.768645 -0.428041
- 0.411337 0.211425 0.377238
- 0.359045 0.0232474 0.617708
- -------- --------- ---------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement