Stats

bootstrap_confidence_interval(truth, pred, stat_function, num_iterations=1000, interval=95.0)[source]

Calculate a 95% confidence interval (CI) for a statistic of interest using bootstrap

Parameters:
  • truth (List[float]) – the true values

  • pred (List[float]) – the predicted values

  • stat_function (Callable[[List[float], List[float]], float]) – the function to calculate the statistic of interest, should return a single value

  • num_iterations (int) – number of bootstrap iterations

  • interval (float) – the confidence interval to calculate

Return type:

Tuple[float, float, float]

Returns:

95% CI lower bound, value of the statistic, 95% CI upper bound

pearson_confidence(r, num, interval=0.95)[source]

Calculate upper and lower 95% CI for a Pearson r (not R**2) Inspired by https://stats.stackexchange.com/questions/18887

Parameters:
  • r (int) – Pearson’s R

  • num (int) – number of data points

  • interval (float) – confidence interval (0-1.0)

Return type:

Tuple[float, float]

Returns:

lower bound, upper bound

max_possible_correlation(vals, error=0.3333333333333333, method=<function pearsonr>, cycles=1000)[source]

Calculate the maximum possible correlation given a particular experimental error Based on Brown, Muchmore, Hajduk http://www.sciencedirect.com/science/article/pii/S1359644609000403 :type vals: List[float] :param vals: experimental values (should be on a log scale) :type error: float :param error: experimental error :type method: Callable[[List[float], List[float]], float] :param method: method for calculating the correlation, must take 2 lists and return correlation and p_value :type cycles: int :param cycles: number of random cycles :rtype: float :return: maximum possible correlation