Created
January 17, 2016 05:30
-
-
Save jameskyle/7ab8e0c99472d83462ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import numpy as np | |
from stdev_code import stdev_p, stdev_s | |
class TestStdevCode(unittest.TestCase): | |
def setUp(self): | |
self.data = [] | |
for x in xrange(100): | |
self.data.append(np.random.uniform(0,50000000000,1000)) | |
def test_population_deviation(self): | |
for data in self.data: | |
self.assertAlmostEqual(stdev_p(data), np.std(data, ddof=0), places=3) | |
def test_sample_deviation(self): | |
for data in self.data: | |
self.assertAlmostEqual(stdev_s(data), np.std(data, ddof=1), places=3) | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment