Is it possible to use a scipy function instead?