예제 #1
0
    def test_crosscorr(self):
        data_local = array([
            array([1.0, 2.0, -4.0, 5.0, 8.0, 3.0, 4.1, 0.9, 2.3]),
            array([2.0, 2.0, -4.0, 5.0, 3.1, 4.5, 8.2, 8.1, 9.1]),
        ])

        sig = array([1.5, 2.1, -4.2, 5.6, 8.1, 3.9, 4.2, 0.3, 2.1])

        data = self.sc.parallelize(zip(range(1, 3), data_local))

        method = CrossCorr(sigfile=sig, lag=0)
        betas = method.calc(data).map(lambda (_, v): v)
        assert (allclose(betas.collect()[0],
                         corrcoef(data_local[0, :], sig)[0, 1]))
        assert (allclose(betas.collect()[1],
                         corrcoef(data_local[1, :], sig)[0, 1]))

        method = CrossCorr(sigfile=sig, lag=2)
        betas = method.calc(data).map(lambda (_, v): v)
        tol = 1E-5  # to handle rounding errors
        assert (allclose(betas.collect()[0],
                         array([-0.18511, 0.03817, 0.99221, 0.06567,
                                -0.25750]),
                         atol=tol))
        assert (allclose(betas.collect()[1],
                         array(
                             [-0.35119, -0.14190, 0.44777, -0.00408, 0.45435]),
                         atol=tol))
예제 #2
0
    def test_crosscorr(self):
        data_local = array([
            array([1.0, 2.0, -4.0, 5.0, 8.0, 3.0, 4.1, 0.9, 2.3]),
            array([2.0, 2.0, -4.0, 5.0, 3.1, 4.5, 8.2, 8.1, 9.1]),
        ])

        sig = array([1.5, 2.1, -4.2, 5.6, 8.1, 3.9, 4.2, 0.3, 2.1])

        data = self.sc.parallelize(zip(range(1, 3), data_local))

        method = CrossCorr(sigfile=sig, lag=0)
        betas = method.calc(data).map(lambda (_, v): v)
        assert(allclose(betas.collect()[0], corrcoef(data_local[0, :], sig)[0, 1]))
        assert(allclose(betas.collect()[1], corrcoef(data_local[1, :], sig)[0, 1]))

        method = CrossCorr(sigfile=sig, lag=2)
        betas = method.calc(data).map(lambda (_, v): v)
        tol = 1E-5  # to handle rounding errors
        assert(allclose(betas.collect()[0], array([-0.18511, 0.03817, 0.99221, 0.06567, -0.25750]), atol=tol))
        assert(allclose(betas.collect()[1], array([-0.35119, -0.14190, 0.44777, -0.00408, 0.45435]), atol=tol))
예제 #3
0
 def runtest(self):
     method = CrossCorr(sigfile=os.path.join(self.modelfile, "crosscorr"),
                        lag=0)
     betas = method.calc(self.rdd)
     betas.count()
예제 #4
0
 def runtest(self):
     method = CrossCorr(sigfile=os.path.join(self.modelfile, "crosscorr"), lag=0)
     betas = method.calc(self.rdd)
     betas.count()