I tried cubic interpolation, but apparently n_max isn't always really the peak value
Turned out that cubic interpolation caused negative values