Now, convert this code into a function instead. Add a docstring in numpy format to it containing a description of what the function does, its inputs and outputs.