Skip to content
Prev 281268 / 398498 Next

find inflexion point of discrete value list with R

Jonas Stein <news <at> jonasstein.de> writes:
[snip]
diff(y) gives you the first difference, the analogue of the gradient
  diff(diff(y)) gives the second difference, the analogue of the second
derivative.

  dy <- diff(y)
  d2y <- diff(dy)
  which(dy==0)  ## critical values
  sign(s2y)[which(dy==0)]  ## test for max/min/saddle
  which(d2y==0)   ## inflection points