def test_invert_lambert(self): # Test if we can transform and transform back mu, sigma, delta = 0.5, 1.7, 0.33 x = np.random.normal(loc=mu, scale=sigma, size=ns) y = g.inverse(x, (mu, sigma, delta)) x_prime = g.w_t(y, (mu, sigma, delta)) assert np.allclose(x, x_prime)
def test_invert_lambert(): # Test if we can transform and transform back mu, sigma, delta = 0.5, 1.7, 0.33 x = np.random.normal(loc=mu, scale=sigma, size=ns) y = g.inverse(x, (mu, sigma, delta)) x_prime = g.w_t(y, (mu, sigma, delta)) assert np.allclose(x, x_prime)
def test_normality_increase_lambert(self): # Generate random data and check that it is more normal after inference for i, y in enumerate([np.random.standard_cauchy(size=ns), experimental_data]): print('Distribution %d' % i) print('Before') print(('anderson: %0.3f\tshapiro: %0.3f' % (anderson(y)[0], shapiro(y)[0])).expandtabs(30)) stats.probplot(y, dist="norm", plot=plt) plt.savefig(os.path.join(self.test_dir, '%d_before.png' % i)) plt.clf() tau = g.igmm(y) x = g.w_t(y, tau) print('After') print(('anderson: %0.3f\tshapiro: %0.3f' % (anderson(x)[0], shapiro(x)[0])).expandtabs(30)) stats.probplot(x, dist="norm", plot=plt) plt.savefig(os.path.join(self.test_dir, '%d_after.png' % i)) plt.clf()
def test_normality_increase_lambert(): # Generate random data and check that it is more normal after inference for i, y in enumerate([np.random.standard_cauchy(size=ns), experimental_data]): print "Distribution %d" % i print "Before" print ("anderson: %0.3f\tshapiro: %0.3f" % (anderson(y)[0], shapiro(y)[0])).expandtabs(30) stats.probplot(y, dist="norm", plot=pylab) pylab.savefig("%d_before.png" % i) pylab.clf() tau = g.igmm(y) x = g.w_t(y, tau) print "After" print ("anderson: %0.3f\tshapiro: %0.3f" % (anderson(x)[0], shapiro(x)[0])).expandtabs(30) stats.probplot(x, dist="norm", plot=pylab) pylab.savefig("%d_after.png" % i) pylab.clf()