Skip to content

Instantly share code, notes, and snippets.

@PyDataBlog
Last active September 30, 2017 16:14
Show Gist options
  • Select an option

  • Save PyDataBlog/429eb0ce34c99679c6680f67eb58d9e0 to your computer and use it in GitHub Desktop.

Select an option

Save PyDataBlog/429eb0ce34c99679c6680f67eb58d9e0 to your computer and use it in GitHub Desktop.
import numpy as np
#store the variables in arrays
prob = np.array([0.25, 0.5, 0.25])
rate_1 = np.array([0.05, 0.075, 0.10])
rate_2 = np.array([0.2, 0.15, 0.1])
# expected return of each investment
expected_return1 = np.sum(prob * rate_1)
expected_return2 = np.sum(prob * rate_2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment