Skip to content

Instantly share code, notes, and snippets.

@zbrasseaux
Last active January 21, 2020 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zbrasseaux/227f0b868842f7ab000daccdc339a239 to your computer and use it in GitHub Desktop.
Save zbrasseaux/227f0b868842f7ab000daccdc339a239 to your computer and use it in GitHub Desktop.
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