4

I have a data set similar to this,

x <- sample(55:100,200,replace = T)
head(x)
# [1] 67 95 97 91 98 81

And I need to find out the converging point of this particular data something similar to gradient descent curve. For that I tried the following,

x_mean <- c()
for (i in 1:length(x)) {
  x_mean[i] <- mean(x[1:i])
}

mean_diff <- c()
for (i in 2:length(x_mean)) {
  mean_diff[i-1]=(x_mean[i] - x_mean[i-1])^2
}

x2 <-seq(1,length(mean_diff),1)
lo <- loess(mean_diff ~ x2,span = 1)
convergence <- predict(lo)
convergence_point <- which.min(convergence)
convergence_point # 79

plot(convergence,ty = "l",lwd = 2)
abline(v = convergence_point, col = "red")

enter image description here

I am not sure whether my finding is correct or not. Is there any alternative way to figure out the converging point ?

Thanks in adavance.

Jaap
  • 81,064
  • 34
  • 182
  • 193
Jibin
  • 323
  • 3
  • 9

1 Answers1

0

From what I understand, converging point, you mean the coordinates at which the straight line passes through the curve, which happens to be the local minimum, or something of that sort (depending on what you are trying to achieve).

You can then try this: locator

If you are running this in RStudio, once you have finished generating the graph, run locator() and place it on the point for which you need the coordinates and then press Escape.

You should now get the X and Y coordinates, if this is what you want.

Ankur Sinha
  • 6,473
  • 7
  • 42
  • 73
  • Thanks for your response. Actually I need the minimum number of samples to describe the behaviour of data, not by manually locating the sample. – Jibin Feb 08 '18 at 13:17