Skip to content

Instantly share code, notes, and snippets.

@jameskyle
Created January 17, 2016 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameskyle/7ab8e0c99472d83462ed to your computer and use it in GitHub Desktop.
Save jameskyle/7ab8e0c99472d83462ed to your computer and use it in GitHub Desktop.
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