Advertisement
Guest User

Untitled

a guest
Jul 12th, 2015
956
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.25 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sat Jul 11 20:21:09 2015
  4. """
  5.  
  6. import random, math, scipy, numpy, tabulate, matplotlib
  7. from tabulate import tabulate
  8.  
  9.  
  10. def Markov(n, s):
  11.    
  12.     '''
  13.    n represents the number of states
  14.    s represents the number of time-steps
  15.    '''
  16.    
  17.     a_11 = random.random()
  18.     a_12 = random.random()
  19.     a_13 = 1 - (a_11 + a_12)
  20.    
  21.     b_11 = random.random()
  22.     b_12 = random.random()
  23.     b_13 = 1 - (b_11 + b_12)
  24.    
  25.     c_11 = random.random()
  26.     c_12 = random.random()
  27.     c_13 = 1 - (c_11 + c_12)
  28.    
  29.     table = [[a_11, a_12, a_13],
  30.            [b_11, b_12, b_13],
  31.            [c_11, c_12, c_13]]
  32.            
  33.     print tabulate(table)
  34.    
  35. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37.  
  38. runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
  39. Reloaded modules: tabulate
  40. --------  --------  ---------
  41. 0.327009  0.539087  0.133904
  42. 0.541266  0.211004  0.24773
  43. 0.569579  0.392514  0.0379069
  44. --------  --------  ---------
  45.  
  46. runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
  47. Reloaded modules: tabulate
  48. --------  --------  ---------
  49. 0.963362  0.759905  -0.723267
  50. 0.676055  0.546022  -0.222077
  51. 0.248199  0.837107  -0.085306
  52. --------  --------  ---------
  53.  
  54. runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
  55. Reloaded modules: tabulate
  56. --------  ---------  --------
  57. 0.713195  0.0273135  0.259492
  58. 0.264634  0.311998   0.423368
  59. 0.477829  0.250097   0.272074
  60. --------  ---------  --------
  61.  
  62. runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
  63. Reloaded modules: tabulate
  64. ---------  ---------  --------
  65. 0.192538   0.0359414  0.77152
  66. 0.0820929  0.541748   0.376159
  67. 0.0801376  0.595351   0.324512
  68. ---------  ---------  --------
  69.  
  70. runfile('/home/raleigh/Downloads/Python-3.4.3/markovchain.py', wdir='/home/raleigh/Downloads/Python-3.4.3')
  71. Reloaded modules: tabulate
  72. --------  ---------  ---------
  73. 0.659396  0.768645   -0.428041
  74. 0.411337  0.211425    0.377238
  75. 0.359045  0.0232474   0.617708
  76. --------  ---------  ---------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement