fix IndexError in internal_minima

Variable i was not initialized prior to its use in line 26 causing an IndexError.