'calculate cumulative probabilities of Monte Carlo results
Parameters
idx : None or list of integers
List of indices into the Monte Carlo results (columns) that should
be used in the calculation
frac : array_like, float
Defines which quantiles should be calculated. For example a frac
of 0.1 finds the 10% quantile, x such that cdf(x)=0.1
Returns
x : ndarray
same as input, TODO: I should drop this again ?
probs : ndarray, (len(x), len(idx))
the quantiles with frac in rows and idx variables in columns'

def cdf(self, x, idx=None):

    idx = np.atleast_1d(idx).tolist()
    mc_sorted = self.get_mc_sorted()
    x = np.asarray(x)
    if ((x.ndim > 1) and (x.shape[1] == len(idx))):
        use_xi = True
    else:
        use_xi = False
    x_ = x
    probs = []
    for (i, ix) in enumerate(idx):
        if use_xi:
            x_ = x[:, i]
        probs.append((np.searchsorted(mc_sorted[:, ix], x_) / float(self.nrepl)))
    probs = np.asarray(probs).T
    return (x, probs)
