Skip to content

Instantly share code, notes, and snippets.

@kaizhu256
Created August 3, 2023 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaizhu256/83f9bc54b8d58ebf5b92645186d30000 to your computer and use it in GitHub Desktop.
Save kaizhu256/83f9bc54b8d58ebf5b92645186d30000 to your computer and use it in GitHub Desktop.
gauss-newton cosine fit pseudo code
aa = SQRT(SUM((yy - avg)^2) * 2.0 / nn)
cos = cosine(pp + ww*tt)
sin = sine(pp + ww*tt)
rr = (cos - yy) * (cos - yy)
hh1 = SUM( sin*sin - rr*cos )
hh2 = SUM(tt * (sin*sin - rr*cos))
hh3 = SUM(tt*tt * (sin*sin - rr*cos))
gg1 = SUM( rr * sin)
gg2 = SUM(tt * rr * sin)
inv = 1 / (hh1*hh3 - hh2*hh2)
delta_pp = inv * (hh3 * gg1 - hh2 * gg2)
delta_ww = inv * (hh1 * gg2 - hh2 * gg1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment