def discretize_val(val, min_val, max_val, num_states):
	"""
	Discretizes a single float
	if val < min_val, it gets a discrete value of 0
	if val >= max_val, it gets a discrete value of num_states-1
	
	Args:
	    val (float): value to discretize
	    min_val (float): lower bound of discretization
	    max_val (float): upper bound of discretization
	    num_states (int): number of discrete states
	
	Returns:
	    float: discrete value
	"""
	state = int(num_states * (val - min_val) / (max_val - min_val))
	if state >= num_states:
		state = num_states - 1
	if state < 0:
		state = 0
	return state