Exemplo n.º 1
0
 def test_orthogonal_target(self):
     """
     Rotation towards target matrix example
     http://www.stat.ucla.edu/research/gpa
     """
     A = self.get_A()
     H = self.str2matrix("""
       .8 -.3
       .8 -.4
       .7 -.4
       .9 -.4
       .8  .5
       .6  .4
       .5  .4
       .6  .3
     """)
     vgQ = lambda L=None, A=None, T=None: vgQ_target(H, L=L, A=A, T=T)
     L, phi, T, table = GPA(A, vgQ=vgQ, rotation_method='orthogonal')
     table_required = self.str2matrix("""
     0.00000   0.05925  -0.61244   1.00000
     1.00000   0.05444  -1.14701   0.12500
     2.00000   0.05403  -1.68194   0.12500
     3.00000   0.05399  -2.21689   0.12500
     4.00000   0.05399  -2.75185   0.12500
     5.00000   0.05399  -3.28681   0.12500
     6.00000   0.05399  -3.82176   0.12500
     7.00000   0.05399  -4.35672   0.12500
     8.00000   0.05399  -4.89168   0.12500
     9.00000   0.05399  -5.42664   0.12500
     """)
     L_required = self.str2matrix("""
     0.84168  -0.37053
     0.83191  -0.44386
     0.79096  -0.44611
     0.80985  -0.37650
     0.77040   0.52371
     0.65774   0.47826
     0.58020   0.46189
     0.63656   0.35255
     """)
     self.assertTrue(np.allclose(table, table_required, atol=1e-05))
     self.assertTrue(np.allclose(L, L_required, atol=1e-05))
     ff = lambda L=None, A=None, T=None: ff_target(H, L=L, A=A, T=T)
     L2, phi, T2, table = GPA(A, ff=ff, rotation_method='orthogonal')
     self.assertTrue(np.allclose(L, L2, atol=1e-05))
     self.assertTrue(np.allclose(T, T2, atol=1e-05))
     vgQ = lambda L=None, A=None, T=None: vgQ_target(
         H, L=L, A=A, T=T, rotation_method='oblique')
     L, phi, T, table = GPA(A, vgQ=vgQ, rotation_method='oblique')
     ff = lambda L=None, A=None, T=None: ff_target(
         H, L=L, A=A, T=T, rotation_method='oblique')
     L2, phi, T2, table = GPA(A, ff=ff, rotation_method='oblique')
     self.assertTrue(np.allclose(L, L2, atol=1e-05))
     self.assertTrue(np.allclose(T, T2, atol=1e-05))
Exemplo n.º 2
0
 def test_orthogonal_target(self):
     """
     Rotation towards target matrix example
     http://www.stat.ucla.edu/research/gpa
     """
     A = self.get_A()
     H = self.str2matrix("""
       .8 -.3
       .8 -.4
       .7 -.4
       .9 -.4
       .8  .5
       .6  .4
       .5  .4
       .6  .3
     """)
     vgQ = lambda L=None, A=None, T=None: vgQ_target(H, L=L, A=A, T=T)
     L, phi, T, table = GPA(A, vgQ=vgQ, rotation_method='orthogonal')
     table_required = self.str2matrix("""
     0.00000   0.05925  -0.61244   1.00000
     1.00000   0.05444  -1.14701   0.12500
     2.00000   0.05403  -1.68194   0.12500
     3.00000   0.05399  -2.21689   0.12500
     4.00000   0.05399  -2.75185   0.12500
     5.00000   0.05399  -3.28681   0.12500
     6.00000   0.05399  -3.82176   0.12500
     7.00000   0.05399  -4.35672   0.12500
     8.00000   0.05399  -4.89168   0.12500
     9.00000   0.05399  -5.42664   0.12500
     """)
     L_required = self.str2matrix("""
     0.84168  -0.37053
     0.83191  -0.44386
     0.79096  -0.44611
     0.80985  -0.37650
     0.77040   0.52371
     0.65774   0.47826
     0.58020   0.46189
     0.63656   0.35255
     """)
     self.assertTrue(np.allclose(table, table_required, atol=1e-05))
     self.assertTrue(np.allclose(L, L_required, atol=1e-05))
     ff = lambda L=None, A=None, T=None: ff_target(H, L=L, A=A, T=T)
     L2, phi, T2, table = GPA(A, ff=ff, rotation_method='orthogonal')
     self.assertTrue(np.allclose(L, L2, atol=1e-05))
     self.assertTrue(np.allclose(T, T2, atol=1e-05))
     vgQ = lambda L=None, A=None, T=None: vgQ_target(
         H, L=L, A=A, T=T, rotation_method='oblique')
     L, phi, T, table = GPA(A, vgQ=vgQ, rotation_method='oblique')
     ff = lambda L=None, A=None, T=None: ff_target(
         H, L=L, A=A, T=T, rotation_method='oblique')
     L2, phi, T2, table = GPA(A, ff=ff, rotation_method='oblique')
     self.assertTrue(np.allclose(L, L2, atol=1e-05))
     self.assertTrue(np.allclose(T, T2, atol=1e-05))
Exemplo n.º 3
0
 def test_orthogonal_target(self):
     """
     Rotation towards target matrix example
     http://www.stat.ucla.edu/research/gpa
     """
     A = self.str2matrix("""
      .830 -.396
      .818 -.469
      .777 -.470
      .798 -.401
      .786  .500
      .672  .458
      .594  .444
      .647  .333
     """)
     H = self.str2matrix("""
       .8 -.3
       .8 -.4
       .7 -.4
       .9 -.4
       .8  .5
       .6  .4
       .5  .4
       .6  .3
     """)
     vgQ = lambda L=None, A=None, T=None: vgQ_target(H, L=L, A=A, T=T)
     L, phi, T, table = GPA(A, vgQ=vgQ, rotation_method='orthogonal')
     T_analytic = target_rotation(A, H)
     self.assertTrue(np.allclose(T, T_analytic, atol=1e-05))
Exemplo n.º 4
0
 def test_orthogonal_target(self):
     """
     Rotation towards target matrix example
     http://www.stat.ucla.edu/research/gpa
     """
     A = self.str2matrix("""
      .830 -.396
      .818 -.469
      .777 -.470
      .798 -.401
      .786  .500
      .672  .458
      .594  .444
      .647  .333
     """)
     H = self.str2matrix("""
       .8 -.3
       .8 -.4
       .7 -.4
       .9 -.4
       .8  .5
       .6  .4
       .5  .4
       .6  .3
     """)
     vgQ = lambda L=None, A=None, T=None: vgQ_target(H, L=L, A=A, T=T)
     L, phi, T, table = GPA(A, vgQ=vgQ, rotation_method='orthogonal')
     T_analytic = target_rotation(A, H)
     self.assertTrue(np.allclose(T, T_analytic, atol=1e-05))