有没有做插值/外推的C#数学库

有没有做插值/外推的C#数学库,c#,math,C#,Math,例如,我有观点 Y X 100 50 90 43 80 32 需要解决y=50的问题 或 Y X 2009年1月1日100 2009年1月3日97 2009年1月4日94 2009年1月5日92 2009年1月6日91 1/7/2009 89 需要解y=1/23/2009我不知道库,但这里有一个简单的割线解算器: class SecantSolver { private int _maxSteps= 10; private double _precision= 0.1;

例如,我有观点

Y X
100 50
90 43
80 32

需要解决y=50的问题

Y X
2009年1月1日100
2009年1月3日97
2009年1月4日94
2009年1月5日92
2009年1月6日91
1/7/2009 89


需要解y=1/23/2009

我不知道库,但这里有一个简单的割线解算器:

class SecantSolver
{
    private int     _maxSteps= 10;
    private double _precision= 0.1;

    public SecantSolver(int maxSteps, double precision)
    {
        _maxSteps= maxSteps;
        _precision= precision;

        if (maxSteps <= 0)
            throw new ArgumentException("maxSteps is out of range; must be greater than 0!");

        if (precision <= 0)
            throw new ArgumentException("precision is out of range; must be greater than 0!");

    }

    private double ComputeNextPoint(double p0, double p1, Func<Double,Double> f)
    {
        double r0 = f(p0);
        double r1 = f(p1);
        double p2 = p1 - r1 * (p1-p0) / (r1-r0); // the basic secant formula
        return p2;
    }

    public double Solve( double lowerBound, double upperBound, Func<Double,Double> f, out String message)
    {
        double p2,p1,p0;
        int i;
        p0=lowerBound;
        p1=upperBound;
        p2= ComputeNextPoint(p0,p1,f);

        // iterate till precision goal is met or the maximum
        // number of steps is reached
        for(i=0; System.Math.Abs(f(p2))>_precision &&i<_maxSteps;i++) {
            p0=p1;
            p1=p2;
            p2=ComputeNextPoint(p0,p1,f);
        }

        if (i < _maxSteps)
            message = String.Format("Method converges in " + i + " steps.");
        else
            message = String.Format("{0}. The method did not converge.", p2);

        return p2;
    }
}

看看你能不能找到你想要的。当然,您仍然需要为您的问题选择合适的插值/外推类型。

我使用的是Math.NET的数值部分

它包含“各种插值方法,包括重心法和样条曲线”


但俗话说,有谎言、该死的谎言和双三次样条插值。

带来了所有标准插值函数。您将发现各种插值/外推函数具有一个通用、简单的接口。与其他解决方案相比的一个特别优势是速度:这些功能经过仔细优化,在多核硬件和大数据上尽可能快

Alglib是GPL许可证,免费版本不并发,商业并发版本付费,仅供其他人参考。它是开源的吗?在哪里可以看到这些函数的代码?
SecantSolver solver= new SecantSolver(200,              // maxsteps
                                      0.00000001f/100   // tolerance
                                      );

string message;
double root= solver.Solve(0.10,   // initial guess (lower)
                          1.0,    // initial guess (upper)
                          f,      // the function to solve
                          out message
                          );