Skip to content

Instantly share code, notes, and snippets.

@maxencerb
Created November 30, 2021 15:54
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 maxencerb/645a87b64802a5a240b7d5d0404f9998 to your computer and use it in GitHub Desktop.
Save maxencerb/645a87b64802a5a240b7d5d0404f9998 to your computer and use it in GitHub Desktop.
Gist for an article about POS
import matplotlib.pyplot as plt
import numpy as np
AGE_MIN = 10
T = 1000
STAKES = [10, 20]
BASE_AGE = [5, 3]
t_max = 15
def fun(t, s):
age = BASE_AGE[s] + t
if age < AGE_MIN:
return 0
else:
return (age - AGE_MIN) * t * 1 * STAKES[s]
def main():
res = np.array([[fun(t, s) for t in range(t_max)] for s in range(len(STAKES))])
t = np.arange(t_max)
fig, ax = plt.subplots()
ax.plot(t, res[0], label='staker 1')
ax.plot(t, res[1], label='staker 2')
ax.plot(t, np.ones(t_max) * T, '--', label='threshold')
legend = ax.legend(loc='upper left', fontsize='x-large')
plt.show()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment