Ejemplo n.º 1
0
 def test_rayleigh_is_rician_high_noise(self):
     '''Verify rayleigh becomes rician high noise scipy's statistics module.
     '''
     # Rayleigh is special case of Rician (A=0)
     sigma = 20
     pM = rayleigh(self.M, sigma)
     pM_rician = rician(self.M, 0, sigma)
     self.assertTrue(np.allclose(pM, pM_rician))
Ejemplo n.º 2
0
    def test_rician_high_noise(self):
        # Generate rician distribution with high noise
        # High noise is where the correction term counts!
        sigma = 20

        # Try out ours
        pM = rician(self.M, self.A, sigma)

        # Compare to scipy implementation
        rv = rice(self.A)
        pM_scipy = rv.pdf(self.M / (sigma**2))
        # Should fail with no correction
        self.assertFalse(np.allclose(pM, pM_scipy))

        # Now correct
        pM_scipy *= self.correction(sigma)
        self.assertTrue(np.allclose(pM, pM_scipy))
Ejemplo n.º 3
0
    def test_rician_low_noise(self):
        # Generate rician distribution with low noise
        sigma = .8  # too small will blow up the correction term for scipy rice.pdf function (see sigma**4 term in denominator)

        # Try out ours
        pM = rician(self.M, self.A, sigma)

        # Compare to scipy implementation
        rv = rice(self.A)
        pM_scipy = rv.pdf(self.M / (sigma**2)) * self.correction(sigma)

        # # Take a gander
        # plt.plot(pM,label='Rician')
        # plt.plot(pM_scipy,label='Rice (scipy)')
        # plt.plot(pM - pM_scipy)
        # plt.legend()
        # plt.show()

        self.assertTrue(np.allclose(pM, pM_scipy))
Ejemplo n.º 4
0
 def test_rayleigh_is_rician_high_noise(self):
     # Rayleigh is special case of Rician (A=0)
     sigma = 20
     pM = rayleigh(self.M, sigma)
     pM_rician = rician(self.M, 0, sigma)
     self.assertTrue(np.allclose(pM, pM_rician))