def percent_finder(data, p):
    """Level finder for percentage contours
	
	This function is a base-level function used by plots_2d.sigma_cont to define the level which contains the requested
	percentage of the data points.
	
	Parameters
	----------
	data : ndarray
		Describes the n-dimensional position of each data point.
	p : float
		Fraction of the data points to be encircled by the contour.
	
	Returns
	-------
	min_value : float
		Level for the contour.
	"""
    from numpy import cumsum, ravel, sort
    from numpy import min as np_min
    from numpy import sum as np_sum
    data_sorted = sort(ravel(data))[::-1]
    data_fraction = cumsum(data_sorted)
    data_fraction /= np_sum(data_sorted)
    try:
        min_value = np_min(data_sorted[data_fraction < p])
    except ValueError:
        min_value = np_min(data_sorted)
    return min_value
