def test_does_good_matrix_return_correct_size_array(self):
     cmat = np.eye(2)
     mu = np.zeros([2, 1])
     ndp = 50  # number of points to generate ellipse shape
     x, y = utilities.generate_ellipse(mu, cmat, ndp)
     self.assertEqual(x.size, ndp)
     self.assertEqual(y.size, ndp)
 def test_does_good_matrix_return_equal_sized_xy_arrays(self):
     cmat = np.eye(2)
     mu = np.zeros([2, 1])
     x, y = utilities.generate_ellipse(mu, cmat)
     self.assertEqual(x.shape, y.shape)
 def test_does_non_symmetric_matrix_return_error(self):
     cmat = np.array([[3, 2], [1, 3]])
     mu = np.zeros([2, 1])
     with self.assertRaises(SystemExit):
         utilities.generate_ellipse(mu, cmat)
 def test_does_non_positive_definite_matrix_return_error(self):
     cmat = np.zeros([2, 2])
     mu = np.zeros([2, 1])
     with self.assertRaises(SystemExit):
         utilities.generate_ellipse(mu, cmat)
Exemple #5
0
mcstat.run_simulation()

# Extract results
results = mcstat.simulation_results.results
chain = results['chain']
s2chain = results['s2chain']
names = results['names']  # parameter names

# plot chain panel
#plt.rcParams["figure.figsize"] = [12, 12]
mcstat.mcmcplot.plot_chain_panel(chain, names)
plt.savefig('chainpanel.eps', figsize=(8, 6), format='eps', dpi=500)

# plot pairwise correlation
mcstat.mcmcplot.plot_pairwise_correlation_panel(chain[:, 0:2], names[0:2])

# calculate contours for 50% and 95% critical regions
c50 = 1.3863  # critical values from chisq(2) distribution
c95 = 5.9915

xe50, ye50 = generate_ellipse(udobj.mu, c50 * udobj.sig[0:2, 0:2])
xe95, ye95 = generate_ellipse(udobj.mu, c95 * udobj.sig[0:2, 0:2])
bxy50 = bananafunction(np.array([xe50, ye50]).T, udobj.a, udobj.b)
bxy95 = bananafunction(np.array([xe95, ye95]).T, udobj.a, udobj.b)

# add countours to pairwise plot
plt.plot(bxy50[:, 0], bxy50[:, 1], 'k-', LineWidth=2)
plt.plot(bxy95[:, 0], bxy95[:, 1], 'k-', LineWidth=2)
plt.axis('equal')
plt.title('2 first dimensions of the chain with 50% and 95% target contours')
plt.savefig('pairwise.eps', format='eps', dpi=500)