Unittest for stoch_eig with KMR matrices

Test 1


In [1]:
# Default values: N=27, epsilon=1e-2, move='sequential', tolerance=0
%run unittest_mpmath_eigen_markov.py


test_left_eigen_vec (__main__.TestComputeStationary) ... FAIL
test_markov_matrix (__main__.TestComputeStationary) ... ok
test_nonnegative (__main__.TestComputeStationary) ... ok
test_sum_one (__main__.TestComputeStationary) ... 
N = 27 , epsilon = 0.01 

v =
[1.78461891799335e-21  2.42134225054374e-22  1.58178136970194e-23  6.62387508250393e-25  1.99714826608159e-26  4.61652363013834e-28  8.50615744246595e-30  1.28233529283406e-31  1.61097398597244e-33  1.70901762889315e-35  6.12170114669528e-33  1.88270136175183e-30  4.99543427984819e-28  1.14702856348822e-25  2.28258684134156e-23  3.93670143903374e-21  5.87552689775785e-19  7.56560492893643e-17  8.36419656032417e-15  7.88435581028452e-13  6.27594722498647e-11  4.16304499257436e-9  2.25939805506081e-7  9.77435245558917e-6  0.000324182689777041  0.00774148263187573  0.118504234134098  0.873420096025387] 

TOL = 0 

ok

======================================================================
FAIL: test_left_eigen_vec (__main__.TestComputeStationary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/oyama/Dropbox/Development/mpmath_eigen_markov/unittest_mpmath_eigen_markov.py", line 134, in test_left_eigen_vec
    self.assertTrue(mp.norm(v - v*mp.mp.matrix(P), 'inf') <= TOL)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 4 tests in 0.020s

FAILED (failures=1)

In [2]:
%run unittest_mpmath_eigen_markov.py --tolerance=1e-24


test_left_eigen_vec (__main__.TestComputeStationary) ... ok
test_markov_matrix (__main__.TestComputeStationary) ... ok
test_nonnegative (__main__.TestComputeStationary) ... ok
test_sum_one (__main__.TestComputeStationary) ... 
N = 27 , epsilon = 0.01 

v =
[1.78461891799335e-21  2.42134225054374e-22  1.58178136970194e-23  6.62387508250393e-25  1.99714826608159e-26  4.61652363013834e-28  8.50615744246595e-30  1.28233529283406e-31  1.61097398597244e-33  1.70901762889315e-35  6.12170114669528e-33  1.88270136175183e-30  4.99543427984819e-28  1.14702856348822e-25  2.28258684134156e-23  3.93670143903374e-21  5.87552689775785e-19  7.56560492893643e-17  8.36419656032417e-15  7.88435581028452e-13  6.27594722498647e-11  4.16304499257436e-9  2.25939805506081e-7  9.77435245558917e-6  0.000324182689777041  0.00774148263187573  0.118504234134098  0.873420096025387] 

TOL = 1e-24 

ok

----------------------------------------------------------------------
Ran 4 tests in 0.013s

OK

Test 2


In [3]:
%run unittest_mpmath_eigen_markov.py --N=3 --epsilon=1e-14


test_left_eigen_vec (__main__.TestComputeStationary) ... ok
test_markov_matrix (__main__.TestComputeStationary) ... ok
test_nonnegative (__main__.TestComputeStationary) ... ok
test_sum_one (__main__.TestComputeStationary) ... 
N = 3 , epsilon = 1e-14 

P =
[[  1.00000000e+00   5.00000000e-15   0.00000000e+00   0.00000000e+00]
 [  3.33333333e-01   4.99600361e-15   6.66666667e-01   0.00000000e+00]
 [  0.00000000e+00   3.33333333e-15   6.66666667e-01   3.33333333e-01]
 [  0.00000000e+00   0.00000000e+00   5.00000000e-15   1.00000000e+00]] 

v =
[4.99999999999992e-15  7.49999999999992e-29  1.49999999999998e-14  0.99999999999998] 

TOL = 0 

ok

----------------------------------------------------------------------
Ran 4 tests in 0.003s

OK

Test 3


In [4]:
%run unittest_mpmath_eigen_markov.py --move='simultaneous' --N=5 --epsilon=1e-15


test_left_eigen_vec (__main__.TestComputeStationary) ... FAIL
test_markov_matrix (__main__.TestComputeStationary) ... ok
test_nonnegative (__main__.TestComputeStationary) ... ok
test_sum_one (__main__.TestComputeStationary) ... 
N = 5 , epsilon = 1e-15 

P =
[[  1.00000000e+00   2.50000000e-15   2.50000000e-30   1.25000000e-45
    3.12500000e-61   3.12500000e-77]
 [  1.00000000e+00   2.50000000e-15   2.50000000e-30   1.25000000e-45
    3.12500000e-61   3.12500000e-77]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]] 

v =
[1.89911354915195e-31  4.74778387287991e-46  1.71056941445903e-45  3.08148791101961e-30  2.77555756156289e-15  0.999999999999997] 

TOL = 0 

FAIL

======================================================================
FAIL: test_left_eigen_vec (__main__.TestComputeStationary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/oyama/Dropbox/Development/mpmath_eigen_markov/unittest_mpmath_eigen_markov.py", line 134, in test_left_eigen_vec
    self.assertTrue(mp.norm(v - v*mp.mp.matrix(P), 'inf') <= TOL)
AssertionError: False is not true

======================================================================
FAIL: test_sum_one (__main__.TestComputeStationary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/oyama/Dropbox/Development/mpmath_eigen_markov/unittest_mpmath_eigen_markov.py", line 128, in test_sum_one
    self.assertTrue(abs(sum(self.v) - 1) <= TOL)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=2)

In [5]:
%run unittest_mpmath_eigen_markov.py --move='simultaneous' --N=5 --epsilon=1e-15 --tolerance=1e-30


test_left_eigen_vec (__main__.TestComputeStationary) ... ok
test_markov_matrix (__main__.TestComputeStationary) ... ok
test_nonnegative (__main__.TestComputeStationary) ... ok
test_sum_one (__main__.TestComputeStationary) ... 
N = 5 , epsilon = 1e-15 

P =
[[  1.00000000e+00   2.50000000e-15   2.50000000e-30   1.25000000e-45
    3.12500000e-61   3.12500000e-77]
 [  1.00000000e+00   2.50000000e-15   2.50000000e-30   1.25000000e-45
    3.12500000e-61   3.12500000e-77]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]] 

v =
[1.89911354915195e-31  4.74778387287991e-46  1.71056941445903e-45  3.08148791101961e-30  2.77555756156289e-15  0.999999999999997] 

TOL = 1e-30 

FAIL

======================================================================
FAIL: test_sum_one (__main__.TestComputeStationary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/oyama/Dropbox/Development/mpmath_eigen_markov/unittest_mpmath_eigen_markov.py", line 128, in test_sum_one
    self.assertTrue(abs(sum(self.v) - 1) <= TOL)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)

In [6]:
%run unittest_mpmath_eigen_markov.py --move='simultaneous' --N=5 --epsilon=1e-15 --tolerance=1e-15


test_left_eigen_vec (__main__.TestComputeStationary) ... ok
test_markov_matrix (__main__.TestComputeStationary) ... ok
test_nonnegative (__main__.TestComputeStationary) ... ok
test_sum_one (__main__.TestComputeStationary) ... 
N = 5 , epsilon = 1e-15 

P =
[[  1.00000000e+00   2.50000000e-15   2.50000000e-30   1.25000000e-45
    3.12500000e-61   3.12500000e-77]
 [  1.00000000e+00   2.50000000e-15   2.50000000e-30   1.25000000e-45
    3.12500000e-61   3.12500000e-77]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]
 [  5.27109897e-77   4.74778387e-61   1.71056941e-45   3.08148791e-30
    2.77555756e-15   1.00000000e+00]] 

v =
[1.89911354915195e-31  4.74778387287991e-46  1.71056941445903e-45  3.08148791101961e-30  2.77555756156289e-15  0.999999999999997] 

TOL = 1e-15 

ok

----------------------------------------------------------------------
Ran 4 tests in 0.002s

OK

In [7]:
import platform
print platform.platform()


Darwin-13.3.0-x86_64-i386-64bit

In [8]:
import sys
print sys.version


2.7.8 (default, Jul  2 2014, 10:14:46) 
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]

In [9]:
import numpy
print numpy.__version__


1.8.1

In [10]:
import mpmath
print mpmath.__version__


0.19