c# - 拟合 Akima 样条曲线

标签 c# curve-fitting mathnet-numerics

我正在尝试使用与此工具相同的方法在 C# 中拟合 Akima 样条曲线:https://www.mycurvefit.com/share/4ab90a5f-af5e-435e-9ce4-652c95c3d9a7

这条曲线给出了我想要的确切形状(曲线在 X = 30M 处达到峰值,样本数据的最高点)

但是当我使用 MathNet 的 Akima 函数并从同一数据集中绘制 52 个点时:

    var x = new List<double> { 0, 15000000, 30000000, 40000000, 60000000 };
    var y = new List<double> { 0, 93279805, 108560423, 105689254, 90130257 };

    var curveY = new List<double>();
    var interpolation = MathNet.Numerics.Interpolation.CubicSpline.InterpolateAkima(x.ToArray(), y.ToArray());

    for (int i=1; i<=52; i++)
    {
        var cY = interpolation.Interpolate((60000000/52)*i);
        curveY.Add(cY);
    }

我根本没有得到相同的曲线,我得到的曲线在 X = 26M 附近达到峰值,看起来更像自然样条曲线:https://www.mycurvefit.com/share/faec5545-abf1-4768-b180-3e615dc60e3a

Akimas 看起来如此不同的原因是什么? (尤其是在峰值方面)

最佳答案

插值方法等待双参数但这是整数 (60000000/52) * i

(60000000/52) * i 更改为 (60000000d/52d) * i

enter image description here

关于c# - 拟合 Akima 样条曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42651039/

相关文章:

c# - 斜率标准误差 c#

c# - 将 Int32.Maximum+ 数值转换为 int32

r - 如何将曲线拟合到直方图

python - 即使提供了良好的猜测,scipy curve_fit 也根本无法正确拟合?

python - 使用幂律拟合方程

c# - Math.NET Numerics 性能不佳且 CPU 使用率低

c# - 有没有办法遍历我的sql结果并将某些名称/值对存储在C#中的其他位置?

c# - Windows Azure 队列 GetMessage 返回 null

c# - mvc javascript 多次

c# - 对列表中对象的属性使用 Math.NET 统计函数的最佳方法