Created
September 17, 2018 15:15
-
-
Save mattwthompson/33bf0c2952ee6bf49e12c5d394c74623 to your computer and use it in GitHub Desktop.
This file contains 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
import random | |
import numpy as np | |
composition = [1/3, 1/3, 1/3] | |
sites = np.zeros(shape=(300,)) | |
val_1 = composition[2] + composition[1] | |
val_2 = composition[2] | |
val_3 = 0 | |
for i, site in enumerate(sites): | |
val = random.random() | |
if val > val_1: | |
sites[i] = 1 | |
elif val > val_2: | |
sites[i] = 2 | |
elif val > val_3: | |
sites[i] = 3 | |
for val in range(4): | |
print(val, len(np.where(sites == val)[0])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment