Example #1
0
 def test_log_likelihood(self):
     """check that log_likelihood returns correct values."""
     train_data = np.array([[1, 0], [2, 0]])
     bandwidth = 0.5
     points = np.array([[3, 0], [4, 0]])
     kde = Kde(train_data, bandwidth)
     log_lhood = kde.log_likelihood(points)
     expected_log_lhood = -12.286938687661852
     self.assertAlmostEqual(expected_log_lhood, log_lhood)
	def test_log_likelihood(self):
		"""check that log_likelihood returns correct values."""
		train_data = np.array([[1,0],[2,0]])
		bandwidth = 0.5
		points = np.array([[3,0],[4,0]])
		kde = Kde(train_data, bandwidth)
		log_lhood = kde.log_likelihood(points)
		expected_log_lhood = -12.286938687661852
		self.assertAlmostEqual(expected_log_lhood, log_lhood)
Example #3
0
def log_likelihood(pair, bandwidth):
	"""returns the likelihood of the test data having arisen
	a kernel trained on the training data with the given 
	bandwidth

	Parameters
	----------
	pair : list
		A list with two entries which contain the training
		and test data. 
	bandwidth : float
		This bandwidth is a scalar which is multiplied by the
		identity matrix to form a bandwidth matrix.  This 
		matrix is then used to perform density estimation.
	"""
	kde = Kde(pair[0], bandwidth)
	log_lhood = kde.log_likelihood(pair[1])
	return log_lhood