Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

c# - Approximation of n points to the curve with the best fit

I have a list of n points(2D): P1(x0,y0), P2(x1,y1), P3(x2,y2) … Points satisfy the condition that each point has unique coordinates and also the coordinates of each point xi, yi> 0 and xi,yi are integers.

The task is to write an algorithm which make approximation of these points

  • to the curve y = | Acos (Bx) | with the best fit (close or equal to 100%)
  • and so that the coefficients A and B were as simple as possible.

I would like to write a program in C # but the biggest problem for me is to find a suitable algorithm. Has anyone would be able to help me with this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Taking B as an independent parameter, you can solve the fitting for A using least-squares, and compute the fitting residual.

The residue function is complex, with numerous minima of different value, and an irregular behavior. Anyway, if the Xi are integer, the function is periodic, with a period related to the LCM of the Xi.

The plots below show the fitting residue for B varying from 0 to 2 and from 0 to 10, with the given sample points.

enter image description here enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...