<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from collections import Counter <EOL> import unittest <EOL> import numpy as np <EOL> from numpy . testing import assert_allclose <EOL> from nose . plugins . attrib import attr <EOL> import pandas as pd <EOL> from quantecon import DiscreteRV <EOL> class TestDiscreteRV ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> x = np . random . rand ( <NUM_LIT:10> ) <EOL> x /= x . sum ( ) <EOL> cls . x = x <EOL> cls . drv = DiscreteRV ( cls . x ) <EOL> def test_Q_updates ( self ) : <EOL> "<STR_LIT>" <EOL> Q_init = np . copy ( self . drv . Q ) <EOL> x = np . random . rand ( <NUM_LIT:10> ) <EOL> x /= x . sum ( ) <EOL> self . drv . q = x <EOL> Q_after = self . drv . Q <EOL> self . assertFalse ( np . allclose ( Q_init , Q_after ) ) <EOL> self . drv . q = self . x <EOL> assert_allclose ( Q_init , self . drv . Q ) <EOL> def test_Q_end_1 ( self ) : <EOL> "<STR_LIT>" <EOL> assert ( self . drv . Q [ - <NUM_LIT:1> ] - <NUM_LIT:1.0> < <NUM_LIT> ) <EOL> @ attr ( "<STR_LIT>" ) <EOL> def test_draw_lln ( self ) : <EOL> "<STR_LIT>" <EOL> draws = self . drv . draw ( <NUM_LIT> ) <EOL> counts = pd . Series ( Counter ( draws ) ) <EOL> counts = ( counts / counts . sum ( ) ) . values <EOL> assert max ( np . abs ( counts - self . drv . q ) ) < <NUM_LIT> </s>
