Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST: Fix test_discrete_rv #412

Merged
merged 1 commit into from
Jun 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions quantecon/tests/test_discrete_rv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
Tests for discrete_rv.py

"""
from __future__ import division
from collections import Counter
import unittest
import numpy as np
from numpy.testing import assert_allclose
from nose.plugins.attrib import attr
import pandas as pd
from quantecon import DiscreteRV


Expand Down Expand Up @@ -49,9 +46,9 @@ def test_Q_end_1(self):
def test_draw_lln(self):
"discrete_rv: lln satisfied?"
draws = self.drv.draw(1000000)
counts = pd.Series(Counter(draws))
counts = (counts / counts.sum()).values
assert max(np.abs(counts - self.drv.q)) < 1e-2
bins = np.arange(self.drv.q.size+1)
freqs, _ = np.histogram(draws, bins=bins, density=True)
assert_allclose(freqs, self.drv.q, atol=1e-2)

def test_draw_with_seed(self):
x = np.array([0.03326189, 0.60713005, 0.84514831, 0.28493183,
Expand Down