Last active
January 21, 2020 23:59
-
-
Save zbrasseaux/227f0b868842f7ab000daccdc339a239 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
import numpy as np | |
# define size of the output | |
SIZE_OF_ARRAY = 50 | |
# start with an empty array | |
end_array = [] | |
for i in range(0, SIZE_OF_ARRAY): | |
temp_arr = [] | |
for j in range(0, SIZE_OF_ARRAY): | |
# create vertical line of value 50 down the middle | |
if j == SIZE_OF_ARRAY/2: | |
temp_arr.append(50) | |
# create salted background | |
else: | |
val = np.random.randint(low=0, high=100, size=2) | |
val = val[1] | |
# 30% of the background is 100, 70% is 0 | |
if val <= 30: | |
temp_arr.append(100) | |
else: | |
temp_arr.append(0) | |
end_array.append(temp_arr) | |
# write to a csv | |
np.savetxt("hw2_05.csv", np.array(end_array), delimiter=',') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment