def percentile(self, val):
try:<EOL><INDENT>out = [self.percentile(vi) for vi in val]<EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>if val <= <NUM_LIT:0>:<EOL><INDENT>out = float(min(self._mcpts))<EOL><DEDENT>elif val >= <NUM_LIT:1>:<EOL><INDENT>out = float(max(self._mcpts))<EOL><DEDENT>else:<EOL><INDENT>tmp = np.sort(self._mcpts)<EOL>n = val * (len(tmp) + <NUM_LIT:1>)<EOL>k, d = int(n), n - int(n)<EOL>out = float(tmp[k] + d * (tmp[k + <NUM_LIT:1>] - tmp[k]))<EOL><DEDENT><DEDENT>if isinstance(val, np.ndarray):<EOL><INDENT>out = np.array(out)<EOL><DEDENT>return out<EOL>
Get the distribution value at a given percentile or set of percentiles.
This follows the NIST method for calculating percentiles.

Parameters
----------
val : scalar or array
    Either a single value or an array of values between 0 and 1.

Returns
-------
out : scalar or array
    The actual distribution value that appears at the requested
    percentile value or values