What is the most efficient way to produce an array of 100 numbers that form the shape of the triangle wave below, with a max/min amplitude of 0.5?
Triangle waveform in m
To use numpy:
def triangle2(length, amplitude): section = length // 4 x = np.linspace(0, amplitude, section+1) mx = -x return np.r_[x, x[-2::-1], mx[1:], mx[-2:0:-1]]