1

I need to calculate the plane coordinates (x,y). There is a trajectory of change and it is necessary to calculate the subsequent coordinates. There is an approximate formula for changing coordinates, it depends on two coefficients k1 and k2 and random noise:

x = k2cos(k1t) + noise
y = k1sin(k2t) + noise

At the input is given a list of 1000 pairs of coordinates x y first thousand seconds (from 0 to 999):

[(0.8990863593574939, 8.475387292276096e-07), (0.8089593833113505, 0. 3534820061950688), (0.5566465706027002, 0.4399620826711653), (0.19273411906364982, 0.19411748737324), (-0. 20981822525965102, -0.19835273653070376), (-0.5703058016775612, -0.44099688186601116), (-0.8164537877967621, -0. 35053466833726243), (-0.8989145629777989, 0.004703700279075586), … (-0.801155143314037, 0. 35638955826565816), (-0.5427749453575453, 0.43887713883486584), (-0.17557562076019273, 0.18985994842390025), (0. 22682425709951057, -0.20256735021079741), (0.5837487993279974, -0.4419853288796921), (0.8236405373374047, -0. 3475501356746985), (0.8984026035824828, 0.009406628459256976), (0.7930484451922395, 0.3592589441057791)]

In response, an array of 1000 pairs for the second thousand seconds (from 1000 to 1999) is expected, example:

[(0.8990863593574939, 8.475387292276096e-07), (0. 8089593833113505, 0.3534820061950688), (0.5566465706027002, 0.4399620826711653), (0.19273411906364982, 0. 19411748737324), (-0.20981822525965102, -0.19835273653070376), (-0.5703058016775612, -0.44099688186601116), (-0. 8164537877967621, -0.35053466833726243), (-0.8989145629777989, 0.004703700279075586), … (-0.801155143314037, 0. 35638955826565816), (-0.5427749453575453, 0.43887713883486584), (-0.17557562076019273, 0.18985994842390025), (0. 22682425709951057, -0.20256735021079741), (0.5837487993279974, -0.4419853288796921), (0.8236405373374047, -0. 3475501356746985), (0.8984026035824828, 0.009406628459256976), (0.7930484451922395, 0.3592589441057791)]
Zephyr
  • 11,891
  • 53
  • 45
  • 80
Valit
  • 11
  • 1
  • so fit `k1,k2` until the abs difference between data and function (without noise) is minimal. `|(k2*cos(k2*t),k1*sin(k1*t)) - data[t]|` In case you know more about the noise you can narrow down the `k1,k2` search from input data properties like avg, trend, frequency ... for more info see [Trying to fit a sine function to phased light curve](https://stackoverflow.com/a/41208993/2521214) – Spektre Dec 03 '20 at 12:11
  • When I tried it in C++ your sample data lead to `k1=0.45158, k2=0.899080` it might be possible to approximately determine the `k1,k2` directly form the frequency of `x` and `y` signal. So find two consequent zero crossings in `x` and the number of samples coresponds to `k1*samples = 6.28` the same goes for `y` and `k2`. After this just fit nearby these values – Spektre Dec 03 '20 at 12:54
  • Thank you very much for your thoughts, I will try it. – Valit Dec 03 '20 at 13:12
  • btw the `-min` and `+max` values in `x` and `y` are the `k2,k1` ... but you have 1 sec interval so you are missing the peaks ... so k1,k2 will be slightly higher ... – Spektre Dec 03 '20 at 19:14

0 Answers0