Make two datasets match by shifting one along x-axis<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I have two datasets, each of which consists of a number of (x,y) pairs. Both have a similar shape when y is plotted vs x, but they are shifted along the x-axis with respect to each other. I would like to find the offset in x required to make the two datasets overlap (see attached images).
Is there an elegant way to do this in JMP? I could write a loop that shifts one dataset by small increments and calculate the xi^2 between the two for each iteration to find which offset gives the best match, but I was wondering if there was a smarter way of doing it.
Re: Make two datasets match by shifting one along x-axisIan,
- Not necessarily
- Yes
- I was thinking of starting with the smaller dataset (i.e. fewer x/y pairs) and calculating the squared difference between each of its datapoints and the (interpolated) y value of the 2nd dataset at the same x value. The x offset between the two datasets where this value becomes a minimum should correspond to best overlap. It shouldn't be too hard to script this, but before doing so, I thought I'd ask if JMP has a built-in function to achieve this goal.
Thanks,
Marcus
Re: Make two datasets match by shifting one along x-axisI don't think you have overlooked anything that's built in.
Useful prescriptions probably depend on what you can and can't assume about the data, and what figure of merit to use:
- Would you expect each sample to have the same number of (x, y) pairs?
- Is it possible that one or more x or y value is missing?
- How would you wish to quantify 'degree of overlap'?