Skip to content

Commit

Permalink
Remove unneeded Jackknife and BCA functions (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptmerz committed Apr 27, 2021
1 parent a1894cb commit 4881733
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions physical_validation/util/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,40 +349,3 @@ def bootstrap(traj, n_samples):
yield traj[resample_idx]
else:
yield traj[:, resample_idx]


def jackknife(traj):
traj = np.array(traj)
if traj.ndim == 1:
n_traj = traj.size
for idx in range(n_traj):
yield np.concatenate((traj[:idx], traj[idx + 1 :]))
elif traj.ndim == 2:
n_traj = traj.shape[1]
for idx in range(n_traj):
yield np.concatenate((traj[:, :idx], traj[:, idx + 1 :]))
else:
raise NotImplementedError(
"trajectory.jackknife() is not implemented for "
"trajectories with more than 2 dimensions."
)


def bca(param, param_boot, param_jack, alpha):
param_boot = np.array(param_boot)
param_jack = np.array(param_jack)
n_boot = param_boot.size

z0 = stats.norm.ppf(np.sum(param_boot < param) / n_boot)
zlow = stats.norm.ppf(alpha / 2)
zhigh = stats.norm.ppf(1 - alpha / 2)

avg_p_jack = np.mean(param_jack)
a = np.sum((avg_p_jack - param_jack) ** 3) / (
6 * (np.sum((avg_p_jack - param_jack) ** 2) ** (3 / 2))
)

a1 = stats.norm.cdf(z0 + (z0 + zlow) / (1 - a * (z0 + zlow)))
a2 = stats.norm.cdf(z0 + (z0 + zhigh) / (1 - a * (z0 + zhigh)))

return np.percentile(param_boot, a1 * 100), np.percentile(param_boot, a2 * 100)

0 comments on commit 4881733

Please sign in to comment.