Beispiel #1
0
	def test_mvn_var(self, var):
		'''Test that MVN gives approx correct variance'''
		var = var.reshape((2,2))
		x = sim.rnorm(100000, mean=np.zeros(2), var=var)
		print np.cov(x.T)
		print np.all(np.cov(x.T) - var < 0.1)
Beispiel #2
0
	def test_mvn_shape(self, mean):
		'''Test that shape and mean behave correctly for MVN'''
		x = sim.rnorm(100, mean=mean, var=np.diag((0.0002,0.0003,0.0004)) )
		assert np.all(x.shape == (100,3) )
		assert np.all(np.abs(mean - np.mean(x,axis=0)) < 1)
Beispiel #3
0
	def test_uvn_degenerate(self, mean):
		'''If var == 0, all draws should equal the mean'''
		x = sim.rnorm(100, mean=mean, var=0)
		assert np.all(x == np.repeat(mean, 100))
Beispiel #4
0
	def test_uvn_var(self, var):
		'''Check that the sample variance is close to the theoretical variance'''
		x = sim.rnorm(100000, mean=0, var=var)
		assert np.abs(np.var(x) - var) < 2	
Beispiel #5
0
	def test_uvn_shape(self, n):
		'''Test that shape and mean behave correctly'''
		x = sim.rnorm(n, mean=n, var=	0.001)
		assert x.shape == (n,)
		assert np.abs(np.mean(x) - n) < 1