func (pks *Peaks) Max(fracOfMaxPersistence float64) int {
	idxs := pks.GetIndices(fracOfMaxPersistence)
	biggest, val := -1, math.Inf(-1)
	for _, pk := range idxs {
		if pks.seq[pk] > val {
			biggest, val = pk, pks.seq[pk]
		}
	}
	return biggest
}
/*
Max returns the index in the original time series `seq` of the peak with the
highest y-value. See GetIndices for fracOfMaxPersistence.
package ppeaks
import (
	"math"
    "sort"
    "github.com/goccmack/godsp"
)
const none = -1
type Peak struct {
	born, died, left, right int
}
func newPeak(startIdx int) *Peak {
	return &Peak{
		born:  startIdx,
		left:  startIdx,
		right: startIdx,
		died:  none,
	}
}
type Peaks struct {
	peaks []*Peak
	seq   []float64
}
func (p *Peak) getPersistence(seq []float64) float64 {
	if p.died == none {
		return math.Inf(1)
	}
	return seq[p.born] - seq[p.died]
}
func GetPeaksInt(seq []int) *Peaks {
	seq1 := godsp.ToFloat(seq)
	return GetPeaks(seq1)
}
func GetPeaks(seq []float64) *Peaks {
	peaks := make([]*Peak, 0, 1024)
	idxtopeak := make([]int, len(seq))
	for i := range idxtopeak {
		idxtopeak[i] = none
	}
	indices := godsp.Range(len(seq))
	sort.SliceStable(indices, func(i, j int) bool { return seq[indices[i]] > seq[indices[j]] })
	for _, idx := range indices {
		lftdone := (idx > 0 && idxtopeak[idx-1] != none)
		rgtdone := (idx < len(seq)-1 && idxtopeak[idx+1] != none)
		il := none
		if lftdone {
			il = idxtopeak[idx-1]
		}
		ir := none
		if rgtdone {
			ir = idxtopeak[idx+1]
		}
		if !lftdone && !rgtdone {
			peaks = append(peaks, newPeak(idx))
			idxtopeak[idx] = len(peaks) - 1
		}
		if lftdone && !rgtdone {
			peaks[il].right++
			idxtopeak[idx] = il
		}
		if !lftdone && rgtdone {
			peaks[ir].left--
			idxtopeak[idx] = ir
		}
		if lftdone && rgtdone {
			if seq[peaks[il].born] > seq[peaks[ir].born] {
				peaks[ir].died = idx
				peaks[il].right = peaks[ir].right
				idxtopeak[peaks[il].right], idxtopeak[idx] = il, il
			} else {
				peaks[il].died = idx
				peaks[ir].left = peaks[il].left
				idxtopeak[peaks[ir].left], idxtopeak[idx] = ir, ir
			}
		}
	}
	sort.SliceStable(peaks, func(i, j int) bool { return peaks[i].born < peaks[j].born })
	return &Peaks{
		peaks: peaks,
		seq:   seq,
	}
}
func (pks *Peaks) GetIndices(fracOfMaxPersistence float64) []int {
	indices := make([]int, 0, len(pks.peaks))
	_, maxPersistence := pks.MinMaxPersistence()
	for _, pk := range pks.peaks {
		if pk.getPersistence(pks.seq)/maxPersistence >= fracOfMaxPersistence {
			indices = append(indices, pk.born)
		}
	}
	return indices
}