added the 1D Python version developed by Alexis Bottero