Skip to content

Instantly share code, notes, and snippets.

@jampekka
Last active June 1, 2021 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jampekka/4eade897feb9888f663a12a50ef16046 to your computer and use it in GitHub Desktop.
Save jampekka/4eade897feb9888f663a12a50ef16046 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
def compensatory_radius(estimate_dispersion, R):
cosarg = estimate_dispersion/R**2
# Cos will go negative when arg > pi/2. arg < 0 makes no sense, so no need to worry about that.
# Trigonometry breaks down for this at pi/2? Could probably have some sort of analytical
# continuation if needed, however pi/2 dispersion leading to center seems implausible for a
# model.
r_2 = R*np.cos(cosarg)
r_2[cosarg > np.pi/2] = np.nan
return r_2
# Just some radius. I think I (JP) got an analytical result that the r_2 is independent
# from R when minimizing (squared?) distance when assuming Gaussian/Von-Mises distribution
# for the phase uncertainty. Seems off that this is dependent on units (R^2 in the formula makes
# this unit-dependent I think).
R = 13
ts = np.arange(0, 30, 0.01)
alphas = np.linspace(0, 10, 3)
for alpha in alphas:
phase_dispersion = ts*alpha
r_2 = compensatory_radius(phase_dispersion, R)
plt.plot(ts, r_2)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment