Skip to content

Instantly share code, notes, and snippets.

@MatthewCaseres
Created August 6, 2022 01:23
Show Gist options
  • Select an option

  • Save MatthewCaseres/25d9ed277d4873cb063676248e178a1d to your computer and use it in GitHub Desktop.

Select an option

Save MatthewCaseres/25d9ed277d4873cb063676248e178a1d to your computer and use it in GitHub Desktop.
npx = jnp.concatenate([jnp.ones((1, q.shape[1])), jnp.cumprod(1 - q, axis=0)[:-1]])
face = jnp.array([1000 * x for x in [100, 500, 250]])
discount_factor = 1/(1.02)
# discount factors for payments by policyholder starting at t = 0
discounts = discount_factor ** jnp.arange(timesteps)[:, jnp.newaxis]
# discounts factors for payments from insurer starting at t = 1 (payouts are at end of year of death)
discounts_lagged = discounts * discount_factor
discounted_claims_cashflows = discounts_lagged * npx * q * face
# Expected present value of claims per policyholder at each point in time
print(discounted_claims_cashflows)
# [[ 14.705884 93.13726 181.37256 ]
# [ 15.376392 168.17256 230.5098 ]
# [ 19.782635 235.45338 317.49338 ]
# [ 22.16076 272.25107 375.31992 ]
# [ 24.43615 307.44678 441.73465 ]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment