This might be a simple question. However, I wanted to get some clarifications of how the following code works.
a = np.arange(8)
a
array([1,2,3,4,5,6,7])
Example Function = a[0:-1]+a[1:]/2.0
In the Example Function, I want to draw your attention to the plus sign between the array a[0:-1]+a[1:]
. How does that work? What does that look like?
For instance, is the plus sign (addition) adding the first index of each array? (e.g 1+2
) or add everything together? (e.g 1+2+2+3+3+4+4+5+5+6+6+7
)
Then, I assume /2.0
is just dividing it by 2
...