Boxcar Function

Boxcar Function#


Boxcar Function Wiki
any function which is zero over the entire real line, except for a single interval, where it is equal to a constant
$\(\text{boxcar}(x) = (b - a)Af(a, b; x) = A(H(x - a) - H(x - b))\)\( \)A\( is a constant<br> \)f(a, b; x)\( is the uniform distribution of \)x\( for the interval \)[a, b]\(<br> \)H(x)$ is the Heaviside step function


import numpy             as np
import matplotlib.pyplot as plt

x = np.linspace(-2, 2, 4001)
A = 20
a = -1
b = 1
y = np.where((x < a) | (x > b), 0, A)
plt.plot(x, y);
../../_images/1914ff3d643a8d1cbe521e010c07c226ba706db476bcb281a8affb71ca9f63d4.png