コード例 #1
0
    def testInitPolynomialModel(self):

        # Defining a polynomial model with no covariance matrix should be the
        # same as one with a diagonal covariance matrix with ones on the diagonal.

        orderList = [0, 2]
        nParameters = len(orderList)
        covariateName = "t"
        regressorNames = ["1", "t^2"]

        polyModel1 = PolynomialModel(self.time, covariateName, orderList)
        polyModel2 = PolynomialModel(self.time, covariateName, orderList, np.diag(np.ones(self.nObservations)))

        self.assertTrue(np.alltrue(polyModel1.designMatrix() == polyModel2.designMatrix()))
コード例 #2
0
    def testInitPolynomialModel(self):

        # Define the input, and derive what the output should be

        orderList = [0, 2]
        nParameters = len(orderList)
        covariateName = "t"
        regressorNames = ["1", "t^2"]
        designMatrix = np.empty((self.nObservations, nParameters))
        for n in range(len(orderList)):
            designMatrix[:, n] = self.time ** orderList[n]

        # Assert if the output is what it should be

        polyModel = PolynomialModel(self.time, covariateName, orderList)
        self.assertTrue(polyModel.nParameters() == nParameters)
        self.assertTrue(polyModel.regressorNames() == regressorNames)
        self.assertTrue(polyModel.nObservations() == self.nObservations)
        self.assertTrue(np.alltrue(polyModel.designMatrix() == designMatrix))
コード例 #3
0
    def testInitPolynomialModel(self):
    
       # Defining a polynomial model with no covariance matrix should be the 
       # same as one with a diagonal covariance matrix with ones on the diagonal.
       
       orderList = [0,2]
       nParameters = len(orderList)
       covariateName = "t"
       regressorNames = ["1", "t^2"] 

       polyModel1 = PolynomialModel(self.time, covariateName, orderList)
       polyModel2 = PolynomialModel(self.time, covariateName, orderList, np.diag(np.ones(self.nObservations)))
       
       self.assertTrue(np.alltrue(polyModel1.designMatrix() == polyModel2.designMatrix()))
コード例 #4
0
 def testInitPolynomialModel(self):
 
    # Define the input, and derive what the output should be 
    
    orderList = [0,2]
    nParameters = len(orderList)
    covariateName = "t"
    regressorNames = ["1", "t^2"] 
    designMatrix = np.empty((self.nObservations, nParameters))
    for n in range(len(orderList)):
        designMatrix[:,n] = self.time**orderList[n]
     
    # Assert if the output is what it should be      
                    
    polyModel = PolynomialModel(self.time, covariateName, orderList)
    self.assertTrue(polyModel.nParameters() == nParameters)
    self.assertTrue(polyModel.regressorNames() == regressorNames)
    self.assertTrue(polyModel.nObservations() == self.nObservations)
    self.assertTrue(np.alltrue(polyModel.designMatrix() == designMatrix))