到目前为止我所拥有的:
public IList<OxyPlot.DataPoint> Points { get; private set; }
public MainViewModel()
{
Points = new List<DataPoint>
{
new DataPoint(38 , 6.5 ),
new DataPoint(59 , 7 ),
new DataPoint(81 , 8 ),
new DataPoint(103 , 12 ),
new DataPoint(125 , 12.2 ),
new DataPoint(147 , 16 ),
new DataPoint(168 , 15.5 ),
new DataPoint(190 , 16.5 ),
new DataPoint(211 , 18 ),
new DataPoint(213 , 19 ),
new DataPoint(215 , 18.5 ),
new DataPoint(219 , 18 ),
new DataPoint(221 , 19 ),
new DataPoint(224 , 18.8 ),
new DataPoint(226 , 18.3 ),
new DataPoint(229 , 18.4 ),
new DataPoint(231 , 19.2 ),
new DataPoint(232 , 20.4 ),
new DataPoint(234 , 19.1 ),
new DataPoint(235 , 18.4 ),
new DataPoint(236 , 19.8 ),
new DataPoint(237 , 19.2 ),
new DataPoint(238 , 18.9 ),
new DataPoint(239 , 18.8 ),
new DataPoint(240 , 18.2 ),
new DataPoint(241 , 16 ),
new DataPoint(242 , 12 ),
new DataPoint(243 , 9 ),
new DataPoint(244 , 5 ),
new DataPoint(245 , 2 ),
new DataPoint(246 , 1 ),
new DataPoint(247 , 0 ),
new DataPoint(248 , 0 ),
};
var f = new Func<double, double, double, double>((x, A, B) => A * x + B * x + A * B * x * x);
var result = Fit.Curve(Points.Select(p => p.X).ToArray(), Points.Select(p => p.Y).ToArray(), f , 20.0) ;
https://numerics.mathdotnet.com/api/MathNet.Numerics/Fit.htm上的API简短说明对我来说还不够清楚,什么是参数
Func<double, double, double> f,
和
double initialGuess