def test_log_likelihood(self):
        model = GARCHModel(0.2, 0.3, 0.4, sc=self.sc)
        n = 10000
        
        ts = np.array(model.sample(n))
        logLikelihoodWithRightModel = model.log_likelihood(ts)
        
        logLikelihoodWithWrongModel1 = GARCHModel(.3, .4, .5, sc=self.sc).log_likelihood(ts)
        logLikelihoodWithWrongModel2 = GARCHModel(.25, .35, .45, sc=self.sc).log_likelihood(ts)
        logLikelihoodWithWrongModel3 = GARCHModel(.1, .2, .3, sc=self.sc).log_likelihood(ts)

        self.assertTrue(logLikelihoodWithRightModel > logLikelihoodWithWrongModel1)
        self.assertTrue(logLikelihoodWithRightModel > logLikelihoodWithWrongModel2)
        self.assertTrue(logLikelihoodWithRightModel > logLikelihoodWithWrongModel3)
        self.assertTrue(logLikelihoodWithWrongModel2 > logLikelihoodWithWrongModel1)
 def test_gradient(self):
     alpha = 0.3
     beta = 0.4
     omega = 0.2
     genModel = GARCHModel(omega, alpha, beta, sc=self.sc)
     n = 10000
 
     ts = np.array(genModel.sample(n))
 
     gradient1 = GARCHModel(omega + .1, alpha + .05, beta + .1, sc=self.sc).gradient(ts)
     for g in gradient1:
         self.assertTrue(g < 0.0)
     
     gradient2 = GARCHModel(omega - .1, alpha - .05, beta - .1, sc=self.sc).gradient(ts)
     for g in gradient2:
         self.assertTrue(g > 0.0)
    def test_log_likelihood(self):
        model = GARCHModel(0.2, 0.3, 0.4, sc=self.sc)
        n = 10000

        ts = np.array(model.sample(n))
        logLikelihoodWithRightModel = model.log_likelihood(ts)

        logLikelihoodWithWrongModel1 = GARCHModel(
            0.3, 0.4, 0.5, sc=self.sc).log_likelihood(ts)
        logLikelihoodWithWrongModel2 = GARCHModel(
            0.25, 0.35, 0.45, sc=self.sc).log_likelihood(ts)
        logLikelihoodWithWrongModel3 = GARCHModel(
            0.1, 0.2, 0.3, sc=self.sc).log_likelihood(ts)

        self.assertTrue(
            logLikelihoodWithRightModel > logLikelihoodWithWrongModel1)
        self.assertTrue(
            logLikelihoodWithRightModel > logLikelihoodWithWrongModel2)
        self.assertTrue(
            logLikelihoodWithRightModel > logLikelihoodWithWrongModel3)
        self.assertTrue(
            logLikelihoodWithWrongModel2 > logLikelihoodWithWrongModel1)
    def test_gradient(self):
        alpha = 0.3
        beta = 0.4
        omega = 0.2
        genModel = GARCHModel(omega, alpha, beta, sc=self.sc)
        n = 10000

        ts = np.array(genModel.sample(n))

        gradient1 = GARCHModel(omega + 0.1,
                               alpha + 0.05,
                               beta + 0.1,
                               sc=self.sc).gradient(ts)
        for g in gradient1:
            self.assertTrue(g < 0.0)

        gradient2 = GARCHModel(omega - 0.1,
                               alpha - 0.05,
                               beta - 0.1,
                               sc=self.sc).gradient(ts)
        for g in gradient2:
            self.assertTrue(g > 0.0)