def pulse(width, value=1):
    """ Returns a vector of (width+1) integer ones. """
return (width + 1) * [value]

def stepconv(vector, width):
    """ Computes the discrete convolution of vector with a "unit"
        pulse of given width.
        Formula: result[i] = Sum[j=0 to width] 1*vector[i-j]
        Where 0 <= i <= len(vector)+width-1, and the "1*" is the value
        of the implied unit pulse function: pulse[j] = 1 for 0<=j<=width.
    """
result = width * [0] + vector
for i in range(len(vector)):
    result[i] = sum(result[i:i + width + 1])
for i in range(len(vector), len(result)):
    result[i] = sum(result[i:])
return result
Create constrained random numbers?