1

I’m trying to find some way to mathematically calculate the number of peaks in a distribution. I know there are various tests (such as Shapiro Wilk) that assess whether a distribution is normal, but I’m not aware of any that actually tell you how many peaks are present. Normally, I’d just do this visually, but this is for a program that involves changes of distribution over time. The end goal is to show how the distribution changes (or doesn’t) from a normal distribution to a multimodal distribution over time — including tracking different numbers of peaks, should that happen. So I need to be able to:

  1. look beyond just whether the distribution is normal or not and
  2. have this happen programmatically, not visually. Does such an algorithm exist?
  • 1
    How do you do it when you do it visually? – Dave Mar 29 '22 at 01:47
  • 1
    There are a lot of peak-finding algorithms in the topic of signal processing. You could compute densities or probabilities and then try a peak-finding algorithm. One option is scipy.signal.find_peaks. – Galen Mar 29 '22 at 01:53
  • If you have a smooth density function, you could also use calculus methods to find local maxima. – Galen Mar 29 '22 at 01:54
  • My initial step is to just look at the histogram and count the peaks visually using my own judgment. I’ve thought about how to translate this to something more quantifiable, but I keep stumbling on how to identify where the troughs fall when the number of peaks may change and not every dip is a trough — especially at the extreme ends of a distribution. If it were only ever going to be bimodal or unimodal, that would be fairly easy, but I could wind up with three or four peaks – CowCookie Mar 29 '22 at 01:59
  • Are you asking about mathematically defined distribution functions or empirical distributions or estimates of distributions based on data? What would be the inputs of the desired algorithm? – whuber Mar 29 '22 at 15:36
  • @whuber I’m essentially trying to count the peaks in a histogram from measurements of a population. – CowCookie Mar 29 '22 at 15:39
  • That's a standard computation. Please explain how your problem differs from the solutions already posted here, such as at https://stats.stackexchange.com/questions/176112. – whuber Mar 29 '22 at 15:42

0 Answers0