Search code examples
pythonderivative

How to find an estimate for the point of inflection of array of numbers? (Python)


Let's say i have an array of numbers. If i sort the array i have a decently smoothed curve. Is there an easy way to get an estimate for the point where the slope of the line increases the most? (I think this is called point of inlection.

Example:

enter image description here


Solution

  • In a digital signal, the derivative correlates to the difference between two adjacent values.

    So to get that, if a is a numpy array:

    a_prime = a[1:] - a[:-1]
    

    What you're looking for is the point at which the derivative of the derivative is the greatest (which isn't the inflection point):

    answer = np.argmax(a_prime[1:] - a_prime[:-1])