Derivative of an array in python?

后端 未结 3 1081
刺人心
刺人心 2021-01-01 01:58

Currently I have two numpy arrays: x and y of the same size.

I would like to write a function (possibly calling numpy/scipy... functions if

3条回答
  •  太阳男子
    2021-01-01 02:19

    Would something like this solve your problem?

    def get_inflection_points(arr, n=1):
        """
        returns inflextion points from array
            arr: array
            n: n-th discrete difference
        """
        inflections = []
        dx = 0
        for i, x in enumerate(np.diff(arr, n)):
            if x >= dx and i > 0:
                inflections.append(i*n)
            dx = x
        return inflections
    
    

提交回复
热议问题