Suppose we have 2 rnorm, rnorm1 = rnorm(100,0,1) and rnorm2 = rnorm(100,1,1) and then we define input = c(rnorm1, rnorm2).
This question really bother me, could anyone give a favor?
For the simplest case, where you have 2 distributions and know the means of each, you can find the cutpoint by calculating the (log) likelihood for each possible cutpoint:
x = rnorm(100, 0, 1)
y = rnorm(100, 1, 1)
combined = c(x, y)
log_lik = function(cutpoint) {
part1 = combined[1:cutpoint]
part2 = combined[(cutpoint + 1):length(combined)]
sum(dnorm(part1, mean = 0, log = TRUE)) +
sum(dnorm(part2, mean = 1, log = TRUE))
}
res = sapply(1:length(combined), log_lik)
plot(res)
which.max(res)
This is just an ad-hoc solution to the problem though, for more robust statistical procedures you probably want to look at something like a changepoint analysis.