It is not clear what you are tying to achieve. There are not really two lists in your example.
It seems like you're trying to do one of these two things:
- Add the first and last element (times 5) to all elements of the array
- Add the value of the previous and next elements (times 5) to each element
For the first objective, you would only be adding scalars to the array so you must not enclose the first/last items in aquare brackets:
import numpy as np
x= np.random.uniform(0, 1, 1000)
x = x[0]*5 + x + x[-1]*5
for the second objective, you could do it using assignments to a copy of the array:
y = x.copy()
y[:-1] += 5*x[1:]
y[1:] += 5*x[:-1]
[EDIT] based on the OP's comment, he needs padding of 5 on each side. the np.pad() function can do it directly:
x = np.pad(x,(5,5),mode="edge")
example:
a = np.array([7,8,9])
np.pad(a,(5,5),mode="edge")
# array([7, 7, 7, 7, 7, 7, 8, 9, 9, 9, 9, 9, 9])