Using Numpy
Assuming you have only 10 points to keep it readable here, I have shown how to create the arrays using Numpy, and accessing its elements.
>>> weights = np.random.randn(10,4)
>>> corners = np.random.rand(4,2)
>>> x=np.dot(weights, corners)
>>> x
array([[ 0.41183813, 0.18830351],
[ 0.10599174, 0.76246711],
[ 0.50235149, 2.76642114],
[ 0.17072047, 0.67126034],
[-0.25400796, -1.20589651],
[-0.04360992, -0.06102023],
[ 0.0446144 , 0.48355716],
[ 0.8501312 , 1.93899732],
[ 0.44656254, 1.05180096],
[ 0.00397146, 0.19248246]])
>>> x_points = np.zeros([10, 2])
Now you have a set of x_points, initialized to 0.0, and your dot product of weights and corners in x.
for i in range(len(x_points)):
x_points[i] = (x[i] + corners[np.random.randint(3)]) / 2
All your randomly initialized points, that took x values, and the corners into consideration have been written to x_points.
>>> x_points
array([[ 0.33206919, 0.25078735],
[ 0.17914599, 0.53786916],
[ 0.46472124, 1.74498146],
[ 0.29890573, 0.69740106],
[-0.08596056, -0.17476289],
[ 0.01923846, 0.39767525],
[ 0.14845732, 0.39841418],
[ 0.46610902, 1.39768402],
[ 0.43682676, 0.88767137],
[ 0.04302915, 0.52442659]])
For simple Python 2D arrays
You create a 2D array as follows:
matrix = [[0 for x in range(num_cols)] for y in range(num_rows)]
Then, you access it like you would access a list with the index:
matrix[2][3] = 23
for i in range(num_rows):
for j in len(num_cols):
print(f"The element in the {i}th row, {j}th col is {matrix[i][j]}")
xis a 100x2 array of points, and you want to average it with some random values fromcorners?