Assume we have a signal, for instance:
x = [1 2 9 16 18 19 18 16 9 7 4 2 1 1 0 0];
and we want to find the location of the signal:
y = [10 8 4 3 1];
which is near to [9 7 4 2 1] and in this example is n = 9.
How can you go about finding n?
As you say, you need to use some sort of cost or likelihood function. Here’s a for loop to start, I’ll let you find the cost function yourself: