コード例 #1
0
ファイル: test_hermite_e.py プロジェクト: AJMartel/3DPrinter
 def test_hermemulx(self):
     assert_equal(herme.hermemulx([0]), [0])
     assert_equal(herme.hermemulx([1]), [0,1])
     for i in range(1, 5):
         ser = [0]*i + [1]
         tgt = [0]*(i - 1) + [i, 0, 1]
         assert_equal(herme.hermemulx(ser), tgt)
コード例 #2
0
 def test_hermemulx(self):
     assert_equal(herme.hermemulx([0]), [0])
     assert_equal(herme.hermemulx([1]), [0, 1])
     for i in range(1, 5):
         ser = [0] * i + [1]
         tgt = [0] * (i - 1) + [i, 0, 1]
         assert_equal(herme.hermemulx(ser), tgt)
コード例 #3
0
    def modelMoments(self, theta, line=0, order=-1):
        """
        Calculate the moments predicted by the model.

        Note, THACO actually calculates the zeroth moment
        """
        noise, center, scale, herm = self.unpackTheta(theta)

        # Since the Probablist's Hermite functions are orthogonal given the unit normal,
        # to integrate the mean and variance just get the weights multiplied by x.
        hermx = hermemulx(herm[line])
        hermxx = hermemulx(hermx)

        normFactor = np.sqrt(2 * np.pi) * scale[line]
        m0 = normFactor * herm[line][0]
        m1 = (center[line] -
              self.linesLam[line]) * m0 + normFactor * hermx[0] * scale[line]
        m2 = normFactor * hermxx[0] * scale[line]**2

        return np.array([m0, m1 * 1e3, m2 * 1e6])