Created
November 3, 2021 21:02
-
-
Save techwithshadab/884c5c31d319a76f11794918fccab2d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index_to_selection(i, num_assets): | |
s = "{0:b}".format(i).rjust(num_assets) | |
x = np.array([1 if s[i]=='1' else 0 for i in reversed(range(num_assets))]) | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment