1. dan mackinlay
  2. bubble-economy

Source

bubble-economy / test_stats.py

#!/usr/bin/env python
# encoding: utf-8
"""
test_stats.py

Created by dan mackinlay on 2010-10-26.
Copyright (c) 2010 __MyCompanyName__. All rights reserved.
"""
import sys
sys.path.insert(0,'.') #why do i need this?

import unittest
import nearness
import numpy as np
import scipy as sp
from scipy.spatial import distance
from numpy.testing import TestCase, assert_array_almost_equal
import stats

class BootstrapTest(TestCase):
    def testBootstrapMultivariate(self):
        """only rows are transposed in your vector valued statistics"""
        test_dat = (np.ones((10,6))*np.linspace(0,5,6))
        self.assertSequenceEqual(
            stats.nonparametric_bootstrap(test_dat, np.mean),
            (2.5, 0.0)
        )
    
    def testUnivariateEstimator(self):
        assert_array_almost_equal(
            (0.0, 0.0), 
            stats.nonparametric_bootstrap(
              np.random.normal(0,1,size=100000), np.mean),
            decimal=2)