<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trim(self):
 		""" 		Trims data based on propensity score to create a subsample with 		better covariate balance. 		 		The default cutoff value is set to 0.1. To set a custom cutoff 		value, modify the object attribute named cutoff directly. 		This method should only be executed after the propensity score 		has been estimated. 		"""


		if 0 < self.cutoff <= 0.5:
			pscore = self.raw_data['pscore']
			keep = (pscore >= self.cutoff) & (pscore <= 1-self.cutoff)
			Y_trimmed = self.raw_data['Y'][keep]
			D_trimmed = self.raw_data['D'][keep]
			X_trimmed = self.raw_data['X'][keep]
			self.raw_data = Data(Y_trimmed, D_trimmed, X_trimmed)
			self.raw_data._dict['pscore'] = pscore[keep]
			self.summary_stats = Summary(self.raw_data)
			self.strata = None
			self.estimates = Estimators()
		elif self.cutoff == 0:
			pass
		else:
			raise ValueError('Invalid cutoff.')