簡體   English   中英

估計曲線的膝部位置

[英]Estimate knee-position of curve

我的測量值看起來像“測量樣本”圖(見代碼)。 從這些點我試圖找到在這種情況下在 x=80 和 y=12 (p.corners[2, ])處的膝蓋。 “底層曲線”圖顯示了我試圖自動找到的趨勢線。

如何估計膝蓋位置的坐標? 我有數百條曲線要擬合,每條曲線大約有 200 個點。

library(ggplot2)
p.corners <- data.frame(rbind(c(0, 6), c(80, 12), c(100, 100)))
colnames(p.corners) <- c("x", "y")
x.a <- 1:p.corners[2, "x"]
y.a <- (p.corners[2, "y"]-p.corners[1, "y"])/(p.corners[2, "x"]-p.corners[1, "x"])*x.a+p.corners[1, "y"]
x.b <- (p.corners[2, "x"]+1):100
y.b <- (p.corners[3, "y"]-p.corners[2, "y"])/(p.corners[3, "x"]-p.corners[2, "x"])*x.b+p.corners[2, "y"]-(((p.corners[3, "y"]-p.corners[2, "y"])/(p.corners[3, "x"]-p.corners[2, "x"]))*p.corners[2, "x"])
x <- c(x.a, x.b)
y <- c(y.a, y.b)
p.random <- data.frame(cbind(x, y))
p.random$y.random <- y + 20*(runif(20)-0.5)

p <- ggplot(p.random, aes(x=x, y=y.random))
p <- p + geom_point()
p <- p + xlim(0, 100)
p <- p + ylim(0, 100)
p <- p + labs(title="Measured samples")
p
p <- ggplot(p.random, aes(x=x, y=y))
p <- p + geom_line()
p <- p + xlim(0, 100)
p <- p + ylim(0, 100)
p <- p + labs(title="Underlying curve")
p

基礎曲線是一條斜率適中的直線,然后是一條陡峭的線。 測量值比示例圖中的分布更廣泛。

沒有實際數據很難判斷,但也許您應該首先查看使用diff計算的diff

> rle(round(diff(p.random$y, differences = 1), 3))
Run Length Encoding
  lengths: int [1:2] 79 20
  values : num [1:2] 0.075 4.4
> rle(round(diff(p.random$y, differences = 2), 3))
Run Length Encoding
  lengths: int [1:3] 78 1 19
  values : num [1:3] 0 4.325 0
> rle(round(diff(p.random$y, differences = 3), 3))
Run Length Encoding
  lengths: int [1:4] 77 1 1 18
  values : num [1:4] 0 4.325 -4.325 0

(這里的rle調用只是為了縮短輸出。)也許您正在尋找二階差分的峰值,或者三階差分的符號變化。 如果數據有噪聲,請考慮使用KernSmooth::ksmoothloess KernSmooth::ksmooth平滑處理。

提出問題后為時已晚,但只是想向您展示另一種解決方案,以防將來變得更容易。 發現這一點:在這最后一段的方法“與最佳的一致性分數的LDA模型,以手肘方法(與最大絕對二階導數的點)獲得(......)” 提出 ,因此它可以幫幫忙,因為它只是幫了我

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM