Triangular window

I want to code a triangular window in an array. The array size is an odd number and indices start from 1.

For example Having the number of elements N = 13

The middle position 7, the value will be 1.0 Then things decrease to zero using a rectangular variation.

Having problem how to code it.

This is simple math. You solve this with algerbra, it's a line from (1,0) to (7,1).

# slope of the line
m = (y1-y2)/(x1-x2)
m = (1-0)/(7-1)
m = 1/6

# solve for b, by putting in x y m
y = mx + b
y - mx = b
1 - (1/6)7 = b
6/6 - 7/6 = b
b = -(1/6)

So, the line is y = (1/6)*x - (1/6)

Got it :b: