{ "metadata": { "name": "", "signature": "sha256:9872238974746ca2920fe7abfd1c6d08512ee1a0d7e436a90b7d78ed5a2a6125" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "import platform\n", "print platform.platform()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Darwin-13.3.0-x86_64-i386-64bit\n" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "import sys\n", "print sys.version" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "2.7.8 (default, Jul 2 2014, 10:14:46) \n", "[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]\n" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "import numpy\n", "print numpy.__version__" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "1.8.1\n" ] } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "# Default values: N=27, epsilon=1e-2, move='sequential', tolerance=0\n", "%run unittest_mc_compute_stationary_mpmath.py" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "test_left_eigen_vec (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_markov_matrix (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_nonnegative (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_sum_one (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stdout", "text": [ "N = 27 , epsilon = 0.01 \n", "\n", "v (converted to numpy.float) =\n", "[ 1.78067089e-21 2.41598563e-22 1.57828207e-23 6.60922140e-25\n", " 1.99273007e-26 4.60631072e-28 8.48733971e-30 1.27949877e-31\n", " 1.60743862e-33 1.70776649e-35 6.12168837e-33 1.88270135e-30\n", " 4.99543428e-28 1.14702856e-25 2.28258684e-23 3.93670144e-21\n", " 5.87552690e-19 7.56560493e-17 8.36419656e-15 7.88435581e-13\n", " 6.27594722e-11 4.16304499e-09 2.25939806e-07 9.77435246e-06\n", " 3.24182690e-04 7.74148263e-03 1.18504234e-01 8.73420096e-01] \n", "\n", "TOL = 0 \n", "\n" ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "\n", "----------------------------------------------------------------------\n", "Ran 4 tests in 0.002s\n", "\n", "OK\n" ] } ], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "%run unittest_mc_compute_stationary_mpmath.py --N=3 --epsilon=1e-14" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "test_left_eigen_vec (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_markov_matrix (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_nonnegative (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_sum_one (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stdout", "text": [ "N = 3 , epsilon = 1e-14 \n", "\n", "P =\n", "[[ 1.00000000e+00 5.00000000e-15 0.00000000e+00 0.00000000e+00]\n", " [ 3.33333333e-01 4.99600361e-15 6.66666667e-01 0.00000000e+00]\n", " [ 0.00000000e+00 3.33333333e-15 6.66666667e-01 3.33333333e-01]\n", " [ 0.00000000e+00 0.00000000e+00 5.00000000e-15 1.00000000e+00]] \n", "\n", "v (converted to numpy.float) =\n", "[ 5.00079054e-15 7.50039527e-29 1.50000000e-14 1.00000000e+00] \n", "\n", "TOL = 0 \n", "\n" ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "\n", "----------------------------------------------------------------------\n", "Ran 4 tests in 0.001s\n", "\n", "OK\n" ] } ], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "%run unittest_mc_compute_stationary_mpmath.py --move='simultaneous' --N=5 --epsilon=1e-15" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "test_left_eigen_vec (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "FAIL\n", "test_markov_matrix (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_nonnegative (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_sum_one (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stdout", "text": [ "N = 5 , epsilon = 1e-15 \n", "\n", "P =\n", "[[ 1.00000000e+00 2.50000000e-15 2.50000000e-30 1.25000000e-45\n", " 3.12500000e-61 3.12500000e-77]\n", " [ 1.00000000e+00 2.50000000e-15 2.50000000e-30 1.25000000e-45\n", " 3.12500000e-61 3.12500000e-77]\n", " [ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00]\n", " [ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00]\n", " [ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00]\n", " [ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00]] \n", "\n", "v (converted to numpy.float) =\n", "[ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00] \n", "\n", "TOL = 0 \n", "\n" ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "\n", "======================================================================\n", "FAIL: test_left_eigen_vec (__main__.TestComputeStationary)\n", "----------------------------------------------------------------------\n", "Traceback (most recent call last):\n", " File \"/Users/oyama/Dropbox/Documents/Teaching/Zemi/2014/test_mc_compute_stationary/unittest_mc_compute_stationary_mpmath.py\", line 133, in test_left_eigen_vec\n", " self.assertTrue(np.allclose(np.dot(self.v, self.P), self.v, atol=TOL))\n", "AssertionError: False is not true\n", "\n", "----------------------------------------------------------------------\n", "Ran 4 tests in 0.002s\n", "\n", "FAILED (failures=1)\n" ] } ], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "%run unittest_mc_compute_stationary_mpmath.py --move='simultaneous' --N=5 --epsilon=1e-15 --tolerance=1e-17" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "test_left_eigen_vec (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_markov_matrix (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_nonnegative (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "test_sum_one (__main__.TestComputeStationary) ... " ] }, { "output_type": "stream", "stream": "stdout", "text": [ "N = 5 , epsilon = 1e-15 \n", "\n", "P =\n", "[[ 1.00000000e+00 2.50000000e-15 2.50000000e-30 1.25000000e-45\n", " 3.12500000e-61 3.12500000e-77]\n", " [ 1.00000000e+00 2.50000000e-15 2.50000000e-30 1.25000000e-45\n", " 3.12500000e-61 3.12500000e-77]\n", " [ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00]\n", " [ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00]\n", " [ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00]\n", " [ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00]] \n", "\n", "v (converted to numpy.float) =\n", "[ 5.27109897e-77 4.74778387e-61 1.71056941e-45 3.08148791e-30\n", " 2.77555756e-15 1.00000000e+00] \n", "\n", "TOL = 1e-17 \n", "\n" ] }, { "output_type": "stream", "stream": "stderr", "text": [ "ok\n", "\n", "----------------------------------------------------------------------\n", "Ran 4 tests in 0.001s\n", "\n", "OK\n" ] } ], "prompt_number": 7 }, { "cell_type": "code", "collapsed": false, "input": [ "import mpmath\n", "print mpmath.__version__" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "0.19\n" ] } ], "prompt_number": 8 } ], "metadata": {} } ] }